Lido Scaggsinsky

Greenhorn
+ Follow
since Sep 16, 2007
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lido Scaggsinsky

Stephan van Hulst wrote:Campbell's form is more flexible. It won't change the way your method works, but it will allow the client to use more argument types.

For instance, if you have a class Fruit extends Comparable<Fruit>, and you have a class Pear extends Fruit, then your current method will only be able to accept Fruits, and not Pears. Using the wildcard, your method can take Pears as well, without any extra effort on your part.



Perfect, thanks!
12 years ago

Campbell Ritchie wrote:By the way, your hasLeft() method is poor style. It would be far better to writeThe generic form is <T extends Comparable<? super T>>



Thanks, that hasLeft() does look cleaner.

What is the difference between the generic form and what I used in my Tree class?

12 years ago

Stephan van Hulst wrote:Hi, Lido. You should probably make your printTree method recursive, so it will print all the nodes in the tree, and it will prevent your code from throwing NullPointerExceptions.

As for your other problem, your addRight method doesn't seem to be working. Take a good look



Ha! Thanks! No wonder....

Yeah, that print method was just some sloppy debugging.
12 years ago
I'm trying to build a basic tree so I can write some test algorithms against it, but I'm getting null pointers and some weird behavior while trying to load the tree with data. Any advice would be appreciated. Is using recursion to find the spot to insert a node a bad idea? What I don't understand is why it's trying to add Lass under Tass, and then after that seems to not go down the right side of the tree and starts placing nodes right under the root ("Mass"). Thanks. Three classes will follow:

Node:


Tree:


TreeTester:
12 years ago
Thanks everyone. That helps a lot.
16 years ago
Thanks. I'd use 1.6, but most of the people who I'm writing this for use Mac and probably won't be upgrading to Leopard any time soon. I heard something on Java Posse about an open jdk 1.6 that someone is working on so I might give that a try.
16 years ago
Thanks. All of those look great. I didn't see any info on any of their sites that indicate that the db can be bundled with an application (in a jar file) and deployed with the application so the end user just double clicks the application file and it all works. Is there a term for that kind of thing?
16 years ago
I'm planning on putting together a (hopefully) simple client/server app which allows users to run a client and access the server app which hosts a database. I was going to use MySQL to handle the data, but I was wondering if there is a way I could bundle a simple database into the server app. That way I could distribute the client and server apps to anyone who has Java on their machine and they could hopefully use the program without having to set up and align a database program themselves. Thanks.
16 years ago
I'm trying to write a static sort class (for practice, I know that there is one already) that takes any ArrayList of comparable objects and sorts it. I've written a generic binary search tree before, but can't seem to get this started.


Is generic types even applicable here? I was also thinking that it could just take an ArrayList of Objects and that object's comparator so it could do the sort on different fields, but I'm not sure how to start that either. It's been a couple of years since I worked with this stuff and I'm trying to brush up, any help would be appreciated. Thanks.
[ September 16, 2007: Message edited by: Lido Scaggsinsky ]
16 years ago