my dog learned polymorphism*
The moose likes Java in General and the fly likes Can not find symbol isEmpty location java.lang.String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can not find symbol isEmpty location java.lang.String" Watch "Can not find symbol isEmpty location java.lang.String" New topic
Author

Can not find symbol isEmpty location java.lang.String

ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
Can any body tell in which jdk this method is added i am using jdk1.6.14 still not able to solve this compile problem
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
api doc says 'since 1.6'
-> http://java.sun.com/javase/6/docs/api/java/lang/String.html#isEmpty()

Are you sure you're using the correct compiler (e.g. type in shell 'java -version')?


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Peter Taucher wrote:Are you sure you're using the correct compiler (e.g. type in shell 'java -version')?
You mean javac -version, surely? Of course, if the java version is wrong, you will still get an error, albeit a different one.
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
ya its giving as jdk 1.3.1 ,

i have set my path to point 1.6 in system properties how command promt shows as jdk 1.3

My path setting -->as oracle is using 1.3 is it the reason it is showing as 1.3 ??
PATH =
C:\jdk1.6\jre\bin\client;C:\jdk1.6\jre\bin\client;D:\app\ixi\product\11.1.0\db_1\bin;C:\orant920\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\MKSNT\bin;
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

That's because the java executable is located in the bin folder, not in the bin\client folder.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
ya got it but problem is not yet solved but it was referring jdk from oracle


now command prompt is showing it as jdk 1.6.14

still i am getting compilation issue

my PATH =
C:\jdk1.6.0_14\bin;C:\jdk1.6.0_14\jre\bin\client;C:\jdk1.6.0_14\jre\bin\client;D:\app\ixi\product\11.1.0\db_1\bin;C:\orant920\bin;C:\MKSNT\bin;C:\MKSNT\bin\X11;C:\MKSNT\mksnt;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Windows Imaging\;C:\IFOR\WIN\BIN;C:\IFOR\WIN\BIN\EN_US;C:\Program Files\IBM\License Use Management\BIN;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\enoviav6r2011x\server\bin\winnt

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

ravindra patil wrote:still i am getting compilation issue

What's the exact error message?

I don't see why this method was added anyway. It's just shorthand for length() == 0. The only advantage is 4 characters less.
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
Ha ha ... it got solved .... it was our application file that was pointing to jdk 1.5


thanks guys ...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Rob Prime wrote:I don't see why this method was added anyway. It's just shorthand for length() == 0. The only advantage is 4 characters less.

Only four characters, but for me it's more about having less cognitive overhead. This seems like a big readability ROI:Less syntactic noise and more expressive; I find isEmpty to be much clearer, and tells a better story when read out loud (my ultimate standard of readability). There's a reason every string utility package has isEmpty() and/or isBlank()...

And both ELs and non-Java JVM languages can call it with foo.empty which is cleaner still--without having to monkeypatch String.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Rob Prime wrote: . . . It's just shorthand for length() == 0. The only advantage is 4 characters less.
Strinjg is a "library class" and you usually put as many methods in a library class as possible, just in case somebody wants to use it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can not find symbol isEmpty location java.lang.String
 
Similar Threads
Can the color for the disabled item be changed
WA #1.....word association
Private methods
URGENT - NEED HELP - Block Code
error in Marcus Green 2.