MrKamal Joshi

Greenhorn
+ Follow
since Jul 31, 2011
MrKamal likes ...
Java
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
7
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by MrKamal Joshi

Seetharaman Venkatasamy wrote:
It is an expected output! constructor calls itself again since you are calling the constructor from instance filed declaration(initialization block)


This means in a class anything outside the method will be implicitly under a initialization block.
10 years ago
I was experimenting with inner class and got some problems

Q1)Line 24.Why we have to redeclare Name inside inner as it was already been declared in outer class and members of outer class are also members of inner class?
Q2)Line 8 or 27 after omitting // and running the program i came across a weird output like that of infinite loop.What's that?
10 years ago
Actually you are making a mistake in printing out the elements of the array loc.You have written System.out.println(loc[cell]); where cell refers to values in array loc,and cell can have value greater than 2 which is outside the bounds of array loc.You have to use System.out.println(cell); for printing out array loc elements.
10 years ago
I tried to populate array by using for each loop but it's not working
10 years ago
Yeah got it.I was making silly mistake.Thanks
10 years ago

Why i am getting NullPointerException here?
10 years ago

Matthew Brown wrote:Why do you have a <T> at the front of your constructor? Try deleting that, and I suspect it will work.

What I think is happening here is that the <T> there is being used to define a generic method. This is separate from the T defining the generic class. So you've actually got two different Ts meaning different things, which leads to a conflict. On line 6 you're trying to assign from one to the other.


So it means that if i have a Generic class class Element<T,S> and i declare 3 constructors <T>Element(){}<S>Element(int a,int b){}<T,S>Element(int a,int b,int c){} then all <T> will be different?
10 years ago
Yeah,It works when i remove <T> in front of the constructor.Thanks
10 years ago

Compiling results in an error
incompatible types
found : T
required: T
this.t=t;
^
Please Explain
10 years ago
Thanks all.
10 years ago
Personally i use Textpad<www.textpad.com/download/>.It provides facility to write,compile and run the code.

10 years ago
You have to declare main as static.main is the entry point of a class. In java everything thing is written in a class.Now when you run java filename on command prompt, loader will load the class and jvm will search the main method to enter into the class. so making the main() as static, will make jvm access it directly through classname.main()
10 years ago

Above code generates output according to previous pattern("\\d") why so?
10 years ago
How the instance of an abstract class is created?As there exist a getInstance() method for an abstract class java.util.Calender.
10 years ago