kiranv

Greenhorn
+ Follow
since May 08, 2000
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 kiranv

herbert,
I did not get your point..
I dont think the code below works
public class test{
int[][] c;
c = new int[][]{{1,2},{3,4}};
}
I have the below code working:
public class test{
public static void main(String args[]){
int[][] c;
c = new int[][]{{1,2},{3,4}};
}
}
or we could do this:
public class test{
static int[][] c;
public static void main(String args[]){
c = new int[][]{{1,2},{3,4}};
}
}
Did I get it correctly?
thnks
Vivek,
Did you put the above code in main mthd, it should work fine...
thnks
interesting Ajith
Got around it with the help of the error mesg!
Waiting for some explanation on this behavior..:-)
Faiza,
1)Create a constructor A(){}
2)Make the return type int for A(int i) method
3)In B(int i), add this line super.A(i)

class A {
int i;
A(){
};
int A(int i) {
this.i = i * 2;
return i;
}
}
class B extends A {
public static void main(String[] args) {
B b = new B(2);
System.out.println(b.i);
}
B(int i) {
super.A(i);
}
}
thanks
kiran
Rahul,
It worked because you said 'java public_test' and not
'java test1'(you already had public_test.class)
I think it will not compile unless you have the main method in test1 class and the file name test1.java..
It looks like only one class declaration CAN have a public declaration in a file with more than class, it is not mandatory..
kiran
Hello,
I have the following code :
Filename:: public_test.java
class test1 {
private void amethod(){
System.out.println("amthod");
}
}

class public_test extends Object
{
public static void main(String args[]){
System.out.println("helo this is public_test");
}
}

Both the above classes are in the same file public_test.java and the program compiles and works fine.
Now, I had read before that when you have more than one class in a file, one of them needs to be declared public.
Here I did not declare any class as public, still it compiles and runs fine.
Pl explain
thanks
kiran
I did have one question on something deprecated in java2