prans rao

Greenhorn
+ Follow
since Aug 08, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by prans rao

what is the difference between applets and web pages.
Please answer me.
I want to know the difference in terms of programming.
Please help me.
15 years ago
Hello
Actually what are static class and general class? what is the difference between them?
In the same way,
what are static method and general method? what is the difference between them?
15 years ago
hi vijayguptha Guptha
you came with fine answer
I have tried as you said
Thatis I have passed arguments like "java cbr 12 24" at runtime.

and i am succeded

THANKS A LOT




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)
{
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();
}
}
15 years ago
hi vijayguptha Guptha
you came with fine answer
I have tried as you said
Thatis I have passed arguments like "java cbr 12 24" at runtime.
But i am getting another error NoClassdefinationFound exception in the below program
please tell me something for that.


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)
{
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();
}
}
15 years ago
When i run the program i am getting array index out of bounds exception
at the step of "Integer.parseInt...."
and at the step, where i tried to print the length of "args"
i am getting that "args has zero elements"
and i couldn't enter the values manually at runtime
here is my program:

class Rectangle
{
int length, breadth;
void show(int x, int y)
{
length = x;
breadth = y;
}
int calculate()
{
return(length * breadth);
}
}
public class enter
{
public static void main(String[] args)
{
System.out.println("args has "+args.length+" elements");
Rectangle rectangle = new Rectangle();
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
rectangle.show(a, b);
System.out.println(" you have entered these values : " + a + " and " + b);
int area = rectangle.calculate();
System.out.println(" area of a rectange is : " + area);
}
}
15 years ago
Sorry to the teachers who replied me
thanks a lot

As you said i have changed the spelling of "length" and compliled it successfully.
But now the problem is with Exception.
When i run the program i am getting array index out of bounds exception
at the step of "Integer.parseInt...."
and at the step, where i tried to print the length of "args"
i am getting that "args has zero elements"
and i couldn't enter the values manually at runtime
here is my program:

class Rectangle
{
int length, breadth;
void show(int x, int y)
{
length = x;
breadth = y;
}
int calculate()
{
return(length * breadth);
}
}
public class enter
{
public static void main(String[] args)
{
System.out.println("args has "+args.length+" elements");
Rectangle rectangle = new Rectangle();
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
rectangle.show(a, b);
System.out.println(" you have entered these values : " + a + " and " + b);
int area = rectangle.calculate();
System.out.println(" area of a rectange is : " + area);
}
}
15 years ago
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.
15 years ago
I am coming with same doubt but in different way
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.
15 years ago
when i run a java program with "Integer.parseInt" in it,
i am getting an error "Array index out of bounds "exception at
that step. But it not showing any compilation error.
Every program i write with that step, i am getting error.
I want to enter values at runtime manually through this, but i am getting that exception.
Here is my one of programs i am getting error.


Here i am getting Exception at "int a1=.."

JCE: please use code tags, they make your code more readable.
[ August 08, 2008: Message edited by: Joe Ess ]
15 years ago