Prasad prap

Greenhorn
+ Follow
since Sep 26, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Prasad prap

what do you mean by "not working in all scenarios"? Can you clarify a bit?
11 years ago
Hi Everyone,

I have an abstract class for which I want to allow only single level of inheritance.
For e.g:




Here I do not want any other class to extend SpecialX. Can I do anything to BaseX to enforce this single level inheritance? I do not have any control over SpecialX so putting restriction on this wont be a solution.

Thanks
11 years ago
Do check this list over Stackoverflow.com
12 years ago
@Eric

This sample of code still is half complete and says very less as others have stated. Edit your post and paste the entire code. Things will be easier for us rather than we guessing on every thing.
12 years ago
Can you post in sample of your code so that your use case make more sense and clear rather than assumptions?
12 years ago
Please watch the signature correctly.

Its is and not .

12 years ago
@Daniel never mind. Thats why this is beginner Java. Do not worry. Shoot your efforts.
Whenever you implement an interface you have to write a definition for methods in the interface.

For e.g:
DO NOT COMPILE THIS CODE. Just observe its concept implementation.



So did you get it why this is wrong?

public static Comparator<Camera> ProductNameComparator
= new Comparator<Camera>()
{
public int compare(Camera camera1, Camera camera2)
{
String productName1 = camera1.getProductName(productName);
String productName2 = camera2.getProductName(productName);

return productName1.compareTo(productName2);

}
};




Let me know if you still need elaboration.
12 years ago
Daniel, Can you post just the snippet(No getter/setter) in the code and the exact error at that line. Things will be lot more easier for everyone.

Anyways,

what is this line just above your constructor doing?

Public class camera implements Comparable



1. Public should be "public".
2. Use case not clear.
3. I believe you used the example literally. I can see Fruit references. Check that out.
12 years ago
@Vijay

Check out this link Throwable

Throwable is the parent class for Errors and Exception. So catch block basically catches Throwable class but we usually write catch(Exception e) often because errors are thrown on much serious accounts. Check out this Stackoverflow
12 years ago
Have a close look at this example:
Comparator example


Let me know if you have trouble fitting that in your example.
12 years ago
implement toString method in Tree class such as



Now call

Tree tree = new Tree(20);

System.out.print(tree); // will print X=20
12 years ago
@daniel

Refer this question. StackOverflow- ClassCastException
12 years ago
Remember null pointer exceptions are always due to no object creation.
12 years ago
What I mean to say is that can I get all process and thread information at once?
Like is it possible for me to access any process any thread?
13 years ago