File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic


prans rao

Joined: Aug 08, 2008
Posts: 9
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]);, 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);
Henry Wong

Joined: Sep 28, 2004
Posts: 20352

Please do *not* start a new topic for each response to an on-going toopic !! Not only is it completely confusing, you lose details which may be useful.

For the record, this topic is a followup to the topic linked below, which I am recommending that you followup to. This topic I will now close.

[ August 08, 2008: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: Exceptions
It's not a secret anymore!