here is the simplest form of the part of the code that got some problem...
public static void main(String[] args) {
String string = "Java C++ C#"; //i put double space after the word Java
String[] str;
int c=0;
str = string.split(" ");
for(String s:str){
if(s==" ")
System.out.println("skipped space");
else{
System.out.println("--"+s);
c++;
}
}
System.out.println("words; " + c);
}
im trying to check if the string contained in the object s is a space but how I do it didn't work.
I want it to output like this
--Java skipped space --C++ --C# words; 3
but the result is
--Java -- --C++ --C# words; 4
Any Suggestions on how can i solve this? or which part i got a problem?
thanks in advance.
This post has been edited by kamirusen: 30 September 2012 - 01:48 AM

New Topic/Question
Reply


MultiQuote



|