You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
Hi i do have problem with this code can any body help me out regarding
public class Main implements Comparable {
public String drink;
public int compareTo(Object o) {
return 0;
}
public static void main(String[] a) {
Main mn1 = new Main();
Main mn2 = new Main();
mn1.drink = "tea";
mn2.drink = "cafe";
TreeSet tree = new TreeSet();
tree.add(mn1);
tree.add(mn2);
////////////////////error block/////////
for(Main m : tree){ types incompatible
//////////////////eb////////////////////
System.out.print(m.drink);
}
For loop definition is wrong. What you really want to do. Give more details about your application.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
I haven't tested it though. Let me know what happens.
__________________ Did this post help you? Please To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. me! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
I don't think so. Again there is incompatible variables found. Isn't it?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
I don't think so. Again there is incompatible variables found. Isn't it?
Like I said I didnt actually test it but your right. After looking at it further this will actually still cause an error.
'Cannot convert from element type Object to main'
__________________ Did this post help you? Please To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. me! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
__________________ Did this post help you? Please To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. me! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.