•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,309 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1673 | Replies: 3
![]() |
I have a few problems.
I want to read in a .dat file with characters like below:
A B C
B * D
D * J
J * *
i used a readLine() from a fileReader, and put all of the characters into a char array.
Then i want to take each character and put it on a stack, but the stack I have to build from scratch, and can only accept Objects. I have no idea how to make chars Objects, because they are inconvertible type.
Secondly I have to put all of these chars into a tree, and print out the tree in proper order. A being parent/root B left child, C right child, and then B's left child is null because of the asterisk, and B's right child is D and so on until J which has no children and its done. I have no idea how to make a tree. I want to make a class Tree, but i don't know what methods to put, I don't know what to do first, I dont know I DONT KNOOOW! and its killing me being so stuck. If anyone knows how to solve any of my problems it would help me immensly, because I'm dying slowly and painfully from this dumb program.
I want to read in a .dat file with characters like below:
A B C
B * D
D * J
J * *
i used a readLine() from a fileReader, and put all of the characters into a char array.
Then i want to take each character and put it on a stack, but the stack I have to build from scratch, and can only accept Objects. I have no idea how to make chars Objects, because they are inconvertible type.
Secondly I have to put all of these chars into a tree, and print out the tree in proper order. A being parent/root B left child, C right child, and then B's left child is null because of the asterisk, and B's right child is D and so on until J which has no children and its done. I have no idea how to make a tree. I want to make a class Tree, but i don't know what methods to put, I don't know what to do first, I dont know I DONT KNOOOW! and its killing me being so stuck. If anyone knows how to solve any of my problems it would help me immensly, because I'm dying slowly and painfully from this dumb program.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
There is a wrapper class Character which can be used to store chars as Objects.
This is equivalent to classes like Integer, Boolean, and Double (among others).
If you're using 1.5 (Tiger, 5.0) that wrapping will be taken care of for you.
If you use the correct Tree from the collections API your sorting will be done for you and all you'll need to do is create an Iterator over the tree (which the Tree can give you) and iterate over that.
The API docs should help you find and use the classes you want.
I find it highly instructive to once in a while just sit back for an hour or so and browse through it. Despite having used Java professionally and fulltime since 1999 I still find things in there I never knew existed.
This is equivalent to classes like Integer, Boolean, and Double (among others).
If you're using 1.5 (Tiger, 5.0) that wrapping will be taken care of for you.
If you use the correct Tree from the collections API your sorting will be done for you and all you'll need to do is create an Iterator over the tree (which the Tree can give you) and iterate over that.
The API docs should help you find and use the classes you want.
I find it highly instructive to once in a while just sit back for an hour or so and browse through it. Despite having used Java professionally and fulltime since 1999 I still find things in there I never knew existed.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- windowsXP, I hate it! (Windows NT / 2000 / XP / 2003)
- Help with Tertiary trees?!?! (Java)
- binary trees (C)
- Trees? (C)
Other Threads in the Java Forum
- Previous Thread: running java on windows 95
- Next Thread: Centering



Linear Mode