• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LinkedList

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I need some help here with my programming homework, so i wish i can get some guidance from you all. That's also my reason for creating an account here.

Main Class
I have 4 objects containing three data types which is Integer, String and String
Lets say:
Object1 = (1,Good day, Hello);
Object2 = (2,New Day, Goodbye);
Object3 = (3, Primary Day, Welcome);
Object4 = (4,Sunrise Day, Farewell);
Then, i add then into my linkedlist.

LinkedList Class (Problem)
My Main focus of this problem is the First String declared Which is Good day, New day, Primary Day, Sunrise day.
I am supposed to Sort them into ascending order based on alphabets
Hence, i decided to use ASCII to sort them.
But in order to use ASCII to sort, I will first have to traverse my linked list, followed by a for loop of my ASCII values and then create a if statement to say if my linkedlist first char is = to ASCII value, then it will sort.

BUT IT IS AN OBJECT, When i cast it to Char, it gives me error.
Also, I have a question here, if i were to cast this linked list to char, will it give me the first letter of the first string, example, the character 'G' from 'Good day' (First object)

I have been thinking about this for a week and it reaching my homework assignment soon. I hope to be able to get some help. Im a new programmer that started learning java only so yeah.

Heres the codes that i have done up to:
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags to your post, and you can see how much better it looks Please always use them.

Your post is confusing and it suggests you are confused. You did not say how much experience you have, but I think you are confusing yourself by trying to do too much all at once. Break your task into small pieces and do them one by one.
Start by reading about object ordering. Then implement ordering for your class. Don't sort anything until you have the ordering correct.
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The String class has a method charAt() that is used to get a particular character in the String. You won't be able to get a specific character by casting a String to Char.

What does the getData() method return?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic