aspose file tools
The moose likes Beginning Java and the fly likes Just little Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Just little Help!" Watch "Just little Help!" New topic
Author

Just little Help!

Wentao Liang
Greenhorn

Joined: Oct 05, 2007
Posts: 13
I can't know why is the flowing code wrong?
Please piont it out.
Regards!
import java.util.*;
public class Test
{
public static void main(String[] args)
{
int storage(String s)
{
return s.length()*2;
}
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
System.out.println(str.storage());

}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35444
    
    9
That depends on what it is supposed to do. Can you tell what that is, and what it is actually doing?

By the way, you should really UseAMeaningfulSubjectLine


Android appsImageJ pluginsJava web charts
Steve De Costa
Ranch Hand

Joined: Jun 04, 2007
Posts: 33
Also,

Please print out the error message you get when you try running the code in the compiler.

Thanks
nilesh purohit
Greenhorn

Joined: Oct 31, 2007
Posts: 4
int Storage(String s) according to this syntax Storage function should be passed with a string when it is called and I think you are not passsing any string hence the error.
hemant chaudhary
Greenhorn

Joined: Feb 22, 2007
Posts: 20
System.out.println(str.storage());


String class has any method called storage ??
[ December 06, 2007: Message edited by: hemant chaudhary ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35444
    
    9
The syntax would not be "str.storage()", it would be "storage(str)". "storage" is not a method of String, it is a method in your own class.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Just little Help!
 
Similar Threads
Scanner
how do i input
InputMismatchException
Problem with accepting a String