Results 1 to 2 of 2
- 02-19-2011, 03:58 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 18
- Rep Power
- 0
Constructors pls explan the code line by line in comments
class Cube1 {
int length;
int breadth;
int height;
public int getVolume() {
return (length * breadth * height);
}
Cube1() {
length = 10;
breadth = 10;
height = 10;
}
Cube1(int l, int b, int h) {
length = l;
breadth = b;
height = h;
}
public static void main(String[] args) {
Cube1 cubeObj1, cubeObj2;
cubeObj1 = new Cube1();
cubeObj2 = new Cube1(10, 20, 30);
System.out.println("Volume of Cube1 is : " + cubeObj1.getVolume());
System.out.println("Volume of Cube1 is : " + cubeObj2.getVolume());
}
}
what does this line do?
public static void main(String[] args) {
Cube1 cubeObj1, cubeObj2;
cubeObj1 = new Cube1();
cubeObj2 = new Cube1(10, 20, 30);
where is the constructor?Last edited by vibaviattigala; 02-19-2011 at 04:16 AM.
-
Please ask a specific question. What in particular do you not understand? If it is the entire code, then your best bet is to start at the beginning of the tutorials and study Java: Java Language Basics
Similar Threads
-
How to read file line by line with fixed number of characters
By trkece in forum New To JavaReplies: 1Last Post: 02-13-2011, 03:09 PM -
Reverse search a Text file from last line to top line
By Jman85 in forum New To JavaReplies: 8Last Post: 12-28-2010, 02:24 PM -
Formatting java command line output - Multi line string
By dricco in forum New To JavaReplies: 2Last Post: 07-02-2010, 02:20 PM -
Need to read an .ini and .abook file line by line (both files contain texts)
By ollyworks in forum Java AppletsReplies: 4Last Post: 09-10-2009, 10:18 AM -
Reading in a line of data and splitting the line up into variables
By guru32 in forum New To JavaReplies: 9Last Post: 04-07-2009, 03:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks