Originally Posted by
javapenguin
I don't know what's in your assignment class, but you don't need that load method.
Also, as it's not in a constructor, your method that calls sort won't know what that array is and will say
cannot find symbol: assign
What is wrong with that? Assign is a variable whose scope is within the view of the load method.
2nd, only a class with a main method will even be able to run the console. I don't see a main method.
The OP could have a main in another class for all we know. There may be a main that just has not been posted.
You should put a Scanner
Scanner console = new Scanner(System.in):
in your main method.
Entirely stylistic, and it would appear that the Scanner is in the main since it is being sent to the load method. It is debatable how to go about this, but what is currently being done is not wrong.
You have the right idea with the for loop.
But you should have each variable be read one at a time and then when you have enough to satisfy your constructor, then you create the new Assignment object. Right now it's going to be confused.
There shouldnt be any real confusion by the JVM. It will read in each value one at a time like it would if it was spread out to multiple lines like you suggest.
And ask for this in the main method.
Also, ti appears that you'll be missing index 0 of your array with your sort method.
It would appear that the array index 0 is taken care of at the first iteration of the loop that uses i as a variable. Either way, I am unclear if the intent of the OP is to miss the index 0, so this could be a real concern.
javapenguin, word of advice, when providing advice be wary if what you are suggesting is
fixing the problem or just
stylistic changes that will more than likely not fix the problem at hand.