Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

beginner

 
prans rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
fred rosenberger
lowercase baba
Bartender
Posts: 12086
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic