im not able to figure out the meaning of this piece of code:
public int void countTokens(String s)
{
StringTokenizer st= new StringTokenizer();
return st.countTokens();
}
im not able to figure out the meaning of this piece of code:
public int void countTokens(String s)
{
StringTokenizer st= new StringTokenizer();
return st.countTokens();
}
The adjective (public) given to a class meaning that it is accessible so you can use this public anywhere in your java project. (int void) means that it will return or give you an integer value. And this method takes/expects a String parameter which is specified in between the brackets and it is (String s). So you specify the data type before the variable name as you did in this example. So, the data type for "s" is "String".. I am not sure what's inside the body does if anyone does know it. Please explain it to us. Thanks in advance.
I hope this helps.
The declaration is wrong. There is no such thing as int void.
It is either int or void. And in this case it should be int:
public int countTokens(String s)
{
StringTokenizer st= new StringTokenizer();
return st.countTokens();
}
okay I found this piece of code in a JAVA EE book,and i knew something was wrong!
Thank you!
I think it means the author of the book was tired and miss-typed :)
Are you sure that you've got that right?
I think it should be...
public int method_name () {} // which should return an int and requires a return statement
OR
public void method_name () {} // which should return nothing and does NOT require a return statement
I think it means the author of the book was tired and miss-typed :)
either that, or it was meant as an: can you see what's wrong here exercise
sometime it just escape from eyes , a method with two return type ahh
we use either one of the return type in method declaration...
either int or void.......
i this code cannot return anything..
code may be wrong..
u cannot use string parameter in the body also..
yes im sure...its a typo! it happens sometimes!
u cannot use string parameter in the body also..
what do you mean by this exactly?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.