Cannot Be Applied To Java.lang.string Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
Java Lang String Cannot Be Applied To Java Lang String
Learn more about Stack Overflow the company Business Learn more about hiring developers object in object cannot be applied android or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Operator Cannot Be Applied To Java Lang String
Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Operator || cannot be applied to java.lang.string operator cannot be applied to java.lang.object int [closed] up vote -4 down vote favorite I am trying to impose || operator on two String.equals() in an if statement as shown below. I am comparing with KeyA or KeyB from properties file with my String myID. if (myID.equals(properties.getString("KeyA")) || myID.equals(properties.getString("KeyB")) { ......... } In the above code myID is type String, and both equals() will return boolean so the above statement should work since boolean java cannot be applied to int || boolean is a valid. But my compiler is giving the below error. Operator && cannot be applied to java.lang.string Can some one point me what I am doing here wrong? java share|improve this question edited Oct 27 '14 at 23:11 asked Oct 27 '14 at 23:05 Vikram 1,96373165 closed as off-topic by Jeroen Vannevel, Sotirios Delimanolis, Jigar Joshi, ApproachingDarknessFish, yshavit Oct 27 '14 at 23:10 This question appears to be off-topic. The users who voted to close gave this specific reason:"This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Jeroen Vannevel, Sotirios Delimanolis, Jigar Joshi, ApproachingDarknessFish, yshavitIf this question can be reworded to fit the rules in the help center, please edit the question. 7 Well, First 'properties.getString("KeyA")' is not valid Java. –Boris the Spider Oct 27 '14 at 23:07 First off, why the single quotes? Second, are you comparing the string that is returned
New Topic programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: Beginning Java Getting
Cannot Be Applied To Java.lang.string Int
a lot of "method cannot be applied to (java.lang.string)" Toshiro Hitsuguya operator cannot be applied java Greenhorn Posts: 19 posted 7 years ago I am trying to write a program that simulates a simple libraray. I am having some trouble applying some of the methods to the main method. Here is my code so far: public class Library { Book[] books; int numBooks; String address; http://stackoverflow.com/questions/26598330/operator-cannot-be-applied-to-java-lang-string void addBook(Book b) { //Adds books to the array of this library books[numBooks] = b; numBooks++; } public boolean borrowBook(Book aBook) { //Marks the book as borrowed return aBook.borrowed(); //refers to a method in another class I created } public boolean returnBook(Book aBook) { //Marks the book as returned return aBook.returned(); } public Library(String street) { //creates new street address street = https://coderanch.com/t/452767/java/java/lot-method-applied-java-lang address; } public String printAddress() { //returns the street address when referenced return address; } public Book printAvailableBooks(Book b) { //supposed take a book out of the list if borrowed for(numBooks = 0; numBooks < 10; numBooks++) { if (numBooks>0) { System.out.println("Were sorry there are no books avalible at this library"); } else if(b.borrowed == false) { //references a varible in the Book class System.out.println("We are sorry this book is checked out."); //this line is supposed to be java.lang.string } else if(b.borrowed == true) { System.out.println(b[numBooks]); } } return b;} public String printOpeningHours(String hours) { hours = "We are open from 9-5."; } public static void main(String[] args){ Library firstLibrary = new Library("10 Main St."); // Create two libraries Library secondLibrary = new Library("228 Liberty St."); firstLibrary.addBook(new Book("The Da Vinci Code"));// Add four books to the first library firstLibrary.addBook(new Book("Le Petit Prince")); firstLibrary.addBook(new Book("A Tale of Two Cities")); firstLibrary.addBook(new Book("The Lord of the Rings")); System.out.println("Library hours:"); // Print opening hours and the addresses printOpeningHours(); System.out.println(); System.out.println("Library addresses:"); firstLibrary.printAddress(); secondLibrary.printAddress(); System.out.println(); // Try to borrow The Lords of the Rings from both libraries System.out.prin
Topic/Question Reply 15 Replies - 11962 Views - Last Post: 16 November 2008 - 07:56 PM Rate Topic: #1 Brandon222 D.I.C http://www.dreamincode.net/forums/topic/72151-error-cannot-be-applied-to/ Head Reputation: 0 Posts: 142 Joined: 16-November 08 Error: cannot be applied to () Posted 16 November 2008 - 03:40 PM Hi...ok well im doing this project where i have to make a program to do online banking...i think im doing it right but i keep getting three errors.. they are: File: C:\Program Files\Java\New Folder\Bank.java [line: 19] cannot be Error: getName(java.lang.String) in Customer cannot be applied to () File: C:\Program Files\Java\New Folder\Driver1.java [line: 6] Error: cannot find symbol symbol : constructor Bank(int) location: class Bank File: C:\Program Files\Java\New Folder\Driver1.java [line: 6] Error: internal error; cannot instantiate Bank.