Prahlad Joshi

Ranch Hand
+ Follow
since Apr 21, 2007
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prahlad Joshi

Thanks Henry and Punit for your clear and detailed explanations.It proved to be a great help for me.

I am not able to understand why the above code is generating the following exception.

Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(
at java.util.AbstractList$Itr.remove(
thanks vishal
16 years ago
how can we draw line graphs in java
16 years ago
Thanks sir for your nice explanation.
Below is the text taken form MIT OCW 6.170

Why would a language have immutable types? Because aliasing is complicated, and when you use immutable types, the issue doesn�t arise. Also, code built with immutable types can sometimes be more efficient.

Where aliasing is defined as two reference variables pointing to same object.
So we can have aliasing that is two reference variables for same immutable object so i can't understand why "the issue doesn't arise".
public class CorrectHashCode
private int number;
public CorrectHashCode(int i)
number = i;
public int hashCode()
int i = (int)(Math.random()*100);
return i*number;
//other methods
it depends upon how equals is being implemented
if you consider two instances of this class to be equal if they have the same value for instance variable then this implementation of hash code is incorrect as it will return different hash code for them.and with this given implementation no two instances of the class can be considered equal.
String toString() is overriding Object toString() method.
16 years ago
one class can be casted to another class if the first class directly or indirectly extends the second class.
a class can be casted to an interface reference type if the class directly or indirectly implements that interface.
i want to run a package containing .class files from a java program for this i have written:
Process tempProcess=Runtime.getRuntime().exec("java "+ mainClassName,null,new;
but the problem is that i am not able to given input to this tempProcess or see output of it.
you can check whether file is created or not by testing whether createNewFile returns true or false.option b is correct(as if file already exists createNewFile returns false).
we can call yield on an instance (as static methods can be called on instances also) but it may have no effect.
yes unless the catch block itself throws an Excption
as far as i have got your question you want to modify main.but main is calling only s1 which handles the exception which may be thrown by s2.If s1 were not catching the Exception only declaring it (as throws Exception instead of present try catch block) yuu have to handle or declare it in main.
we can call only those methods on reference of super type (e.g. s in this case) those are defined or declared in it.
i.e. toString is declared within List and defined(default implementation) in Object.