This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 230
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: 38441
    
  23
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: 230
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: 19674
    
  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: 230
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: 19674
    
  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: 230
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: 38441
    
  23
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