• Post Reply Bookmark Topic Watch Topic
  • New Topic

Just little Help!  RSS feed

 
Wentao Liang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Steve De Costa
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also,

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

Thanks
 
nilesh purohit
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println(str.storage());


String class has any method called storage ??
[ December 06, 2007: Message edited by: hemant chaudhary ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!