Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Ankush Kaundal

Ranch Hand
+ Follow
since May 12, 2011
Ankush likes ...
Eclipse IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankush Kaundal

Hi Gautam,

I think there is one more confusion here. Please note that

String s1=Thread.currentThread().getName();

will give you the name of current thread which is "main" and not Thread1 which i think you are assuming.
And regarding == so it is should be used for comparing references and not the content and if you want to check for equality then you should use equals(Object anObject)method.
However you will notice that in some cases == returns correct result, which is again due to another concept known as String Pooling in Java. For e.g:-
Suppose you have 2 strings declared as,
String s1 = "testString";
String s2 = "testString";

In this case s1==s2 will return true and which is because of String Pooling.
But i would say the best practice to check for equality should be using public boolean equals(Object anObject) method.
6 years ago
The better way can be to run and test the code via command line which can help to learn the basics in a more effective way...
6 years ago

Amrita Rath wrote:yes that was the confusion.Can you please guide me how I am getting the value of i=8.



It is simple, if you convert octal value '010' to decimal then that is equivalent to 8 and that's why you are getting 8 as an output.
6 years ago
Hi Friends,

Can anyone help me on this topic because i am not able to figure out when we can get these fields into use practically?
7 years ago
But still is there any way to find out the optimal initial capacity or it is just hit and trial?
7 years ago
Is there any logic which can help us in deciding ideal initial capacity of an ArrayList if we know the approximate no. of data entries to be stored?
7 years ago
Mostly use will use abstract class to have contract with all child classes that implements it in a way that child classes must provide the implementation for the methods which are declared as abstract in parent class(unless the child class is also abstract).
For Example:- you may declare class Animal as abstract and let us say you have abstract method walk() in this class, then all the child classes(let us say Dog and Cat) must define how both these animals walk.
So you can not create object of Animal class because if you look it in a broad way then animal is an abstract term for all the animals and each type of animal will have its own walking style.
7 years ago
"@Timothy Stockdale" The code is absolutely fine, please check for the duplicate class name as said by Rishi.
7 years ago
Can't we proceed like this, create a static counter variable in the class which should behave as singleton and then use that variable to ensure that not more than one instance is created, probably by checking the value of the static variable in the constructor and also increment it each time in the constructor every time the instance is created(constructor will be called each time the instance is created). ??
7 years ago
See the range is the range of the subset which you have set, since 629 is outside the range of subset (608 to 611, where 608 is inclusive and 611 is exclusive) thats why you are getting the exception.
7 years ago
response.encodeURL("somevalue") -> here encodeURL will add extra session ID info to the end of the URL.
but if you want to redirect to some other URL and still want to maintain session then use response.encodeRedirectURL("somevalue").
7 years ago

Richards Milan wrote:I need to turn off my system by pressing a "Turn Off Computer" button in my java application. Can anyone help me in getting the code for that....?? I am using WINDOWS 7 HOME PREMIUM



Well you can try doing this by getting reference to the runtime object associated with your java application (use static method getRuntime() of Runtime class for the same) and then pass on the String array mentioning the shutdown command and the required arguments to the exec(String[] cmdarray) method of the Runtime class. I think it will work then.
7 years ago

vinayGuddu Pandey wrote:Hi,Can anyone tell me the method with basics example of object class.and where I can use it.and please give detail about equal(Object obj) and ==.



I will suggest to refer to the API if in case you need to know anything about the java packages or classes as they will always give you the correct description. In fact create your local copy of the API documentation using the javadoc and try to refer to it regularly, you will definitely gain a lot.
7 years ago
I think in the start one should go with the command line so as to learn basic things about java such as syntax, package structures etc. and once you are confident enough about the basics then go for the IDE.
7 years ago
The exception is coming because your variable intMoney is not initialized as you have not called the static method program1() so solution is to either call this method or put the code on line 09 in static block rather than in method.
7 years ago