wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Need help finding assignments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help finding assignments" Watch "Need help finding assignments" New topic
Author

Need help finding assignments

Cody Peterson
Greenhorn

Joined: Feb 28, 2012
Posts: 6
Hello all!

I am not sure if this is in the right place, so if not, please move the thread. I'll try and keep this brief.

I am currently taking a computer science course and we're using Java as the language for the course. So far, I am really liking learning Java but I am having some difficulties with the class (my programming background is mostly C and x86 assembler). My professor is excellent, but one problem I have is his emphasis on not wanting us to repeat what he's already done in class, or repeating examples. This means that the homework (which counts for no points) takes the concepts we've discussed, and asks us to accomplish tasks using these concepts which go a bit beyond the basics. The problem I seem to be having is that these more complicated assignments don't give me much time to practice with the basic concepts before moving on to more complicated stuff. Since the homework counts for no points, all of the grading comes from exams and quizzes which is even more complicated than the homework and I feel that in order to REALLY learn and understand Java, I need more practice than one assignment per week.

With that in mind, I was wondering if anyone knows of some good resources such as example assignments, that could help me with the things I am having problems with such as generics, Java Collections Framework, and array-based lists. I've tried looking around a bit on my own, but since these are topics I am struggling with, it's tough for me to determine whether an example is good or not. Or, if anyone wants to give me an assignment that uses these concepts in a way that's basic, but not elementary, I would be most grateful

Thanks!
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Generics are simply hard to grasp at first. Usually people just go with simple cases until they need (or are interested in) the more complex details of generics.

What problems are you having with the Collections Framework, and "array-based lists" (I'm assuming you're referring to ArrayList)?

Maybe you can give us an example of one of the homework assignments you think is difficult, and explain why you don't understand it fully.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
. . . and welcome to the Ranch
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11420
    
  16

Our own Cattle Drive has some assignments you can look at.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Cody Peterson
Greenhorn

Joined: Feb 28, 2012
Posts: 6
Hi all. Thank you all very much for the followups and suggestions. In looking through some books, I've found some exercises that I can use. Please note that these exercises are completely unrelated to any homework and the homework we do get in class, is for practice only and does not count for points.

The first assignment I picked for myself is at the starting comments of the below code which also meets the requirements (as far as I know)



I've verified that this is working as intended using the below Main.java:



Which outputs:
Largest Number is:900
Smallest number is:4

So, my first question is for all intents and purposes, does the above look fine? Have I committed any egregious offenses?

The next assignment I am going to take on relates to the above:

Modify the MyList class that you wrote for Programming Challenge 1 so the type param-eter T should accept any type that implements the Comparable interface. Test the class in a program that creates one instance of MyList to store Integers, and another instance to store Strings.


To approach this, I have referred to the section of my book which covers, "constraining a type parameter to a type that implements an interface," which seems like what I need to do here. Unfortunately, I can't seem to figure out how to do that =/

Would it be


As I understand it, when working with generics, extends also means "implements." So in this case, we are saying that type passed to T must implement the comparable interface. Yes? If so, does the above line of code meet that requirement?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
Yes, that means you want it to implement Comparable. But Comparable isn’t Comparable; it is Comparable<T>. You you often want <T extends Comparable<? super T>> (more details here).
Cody Peterson
Greenhorn

Joined: Feb 28, 2012
Posts: 6
Campbell Ritchie wrote:Yes, that means you want it to implement Comparable. But Comparable isn’t Comparable; it is Comparable<T>. You you often want <T extends Comparable<? super T>> (more details here).


Thank you very much for that. It was very helpful.

On another note, sort of a shameless bump but does anyone have any additional suggestions as to where I can get more practice with this?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
You’re welcome
Have you searched this forum? This sort of question comes up every few weeks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help finding assignments