wood burning stoves*
The moose likes Beginning Java and the fly likes beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "beginner" Watch "beginner" New topic
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: 10916
    
  12

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");


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: beginner
 
Similar Threads
Exceptions
Exceptions
Exceptions
Interesting problem in Java with pass by reference
exceptions