• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mass confusion over AvlTree and Sets and Maps  RSS feed

 
David Burt
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay so i'm pretty new to programming in general and I'm in a data structures class. Our teacher dumped a pretty big project on us and didn't really do the best job of explaining. We've asked him every question we can think of but we're having a hard time communicating because he's only recently moved here and there is a language barrier. this is the class we're supposed to be using

AvlTree.java

we are supposed to use this code to create a map and set called AvlMap and AvlSet to make a concordance from a text file. concordance meaning that it makes a list of every word and then tells you the line numbers that word appears on.

now I understand the difference between a Map and a Set but how do I use them to make a concordance? do i use the words as the keys that refer to sets of line numbers? and should the AvlMap and AvlSet classes just use the AvlTree class or do they extend it? I haven't started writing the AvlMap and AvlSet classes yet because I don't know exactly what they do. I'm also confused by using inheritance so could someone explain the first part of the AvlTree class that goes like this?



What is AnyType and where did it come from? what exactly are <> used for? and what does ? super mean?

Sorry so long I'm just really confused
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch David.

You are new to programming. So let us start with the basics. Forget what your teacher has told you. Without grasping the fundamentals, you will not be successful in writing or understanding code. Are you completely new to programming? Or are you new only to Java language?
 
David Burt
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to programming in general. Java is my first language
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. There is a book called "Head First Java" by Kathy-Bert. Get a copy of that. Start studying. Devote an hour to 2 daily. Make notes of what you do not understand. Then ask questions here. Will be happy to help. As it stands currently, the problem you have been given is , in my opinion, not to be demanded off a beginner to the language. Get your fundamentals about the following crystal clear before you embark on any assignment:

a) declarations,
b) access-specifiers,
c) memory allocation,
d) Object Oriented paradigm( Inheritance, Abstraction, Polymorphism, Overloading and overriding of methods)
e) Flow control, Strings in Java ,
f) Assignments
g) Operators
h) Collections
i) Generics

Without these fundamentals, you will not be able to understand anything in Java. Give yourself time. Study these carefully. Come back with doubts and queries.
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I suggest you have a look at the Java tutorials; there are two sections about generics: 1 2. that is a rather complicated generic declaration. I think (not certain) that it should readThe type T could mean anything. But that anything has to implement the Comparable interface¹
Now that Comparable is itself generic, so it has to be declared with a formal type parameter, so you put that in another pair of <> brackets.
Now you don’t know whether that comparable is to T itself, or indirectly via one of its superclasses. Because you don’t know, you write ?
But you do know one thing. If T implements Comparable, then it implements it itself, or one of its superclasses² does so. So you can add super T to the ?
And there you are.

¹In generics you always use the extends keyword, even when you are implementing an interface.
²In generics, any type is regarded as a subtype of itself and as a supertype of itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!