| Author |
beginner
|
prans rao
Greenhorn
Joined: Aug 08, 2008
Posts: 9
|
|
I am coming with a As joe ess said i tried to print the lenth of "s" as import java.io.*; class cbr { int a,b; void read(int x,int y) { a=x; b=y; } void swap(cbr x1) { int t=x1.a; x1.a=x1.b; x1.b=t; } void display() { System.out.println(a+" "+b); } public static void main(String []s) { System.out.println("s has "+s.lenght+" elements"); cbr c=new cbr(); int a1=Integer.parseInt(s[0]); int a2=Integer.parseInt(s[1]); c.read(a1,a2); System.out.println("Before swap"); c.display(); System.out.println("After swap"); c.swap(c); c.display(); } } But i am getting error as cannot resolve symbol "s". what to do please suggest me as soon as possible.
|
 |
venkatesh badrinathan
Ranch Hand
Joined: Aug 03, 2008
Posts: 77
|
|
Hi prans, i think the problem is not with your concept but your spelling for 'length' check out in this line, System.out.println("s has "+s.lenght+" elements"); Furthur the compiler did not report like what you have said..
|
SCJP1.5
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9940
|
|
read the error more closely. what it actually says is:
cbr.java:22: cannot find symbol symbol : variable lenght location: class java.lang.String[] System.out.println("s has "+s.lenght+" elements");
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: beginner
|
|
|