I am confused now...I do implement the comparable interface dont I? I implement the compareTo method in Person Class ... The API documentation for the Comparable interface mentions only compareTo(T...
Type: Posts; User: bihlas
I am confused now...I do implement the comparable interface dont I? I implement the compareTo method in Person Class ... The API documentation for the Comparable interface mentions only compareTo(T...
public class Person implements Comparable<Person>
{
// the age of the person
private int age;
//the name of the person
private String name;
//the Integer object to wrap the...
Thank you Cornix.... Greg I used the for loop because I saw it in an example in my book and I just liked the fact you can declare the Iterator inside the condition...I have seen that is more common...
public void createPersons()
{
Random rand = new Random();
for(int index = 0; index < persons.length; index++) {
Person person = new Person(rand.nextInt(maxAge),...
I am trying to execute a program from the command prompt. I type java -jar zuul.jar (zuul is the name of my project) and I get a message that java is not recognized as an internal or external...
And if it is the same generate a new random number? And if it is the same again? generate a new and so on...
Anyway I am giving up, I cant short this out in a definite manner, I can ensure that it...
You mean is impossible?~X( I cant understand why a book has an exercise that it has no possible solution.... It mentions though that it is a quite challenging programming exercise...
My concern was not to return the same random number twice in the row and not to ensure that the same random number wont be returned at all...
Do you have any suggestion to that?
To put you in the...
Well, not in theory... trying to solve this problem with a similar idea, I declared a field inside the class to hold the result of the previous returned number and use that in a condition statement...
I want to use this idea in a different context but for the sake of the argument lets suppose I have this method:
public int random number(int range)
{
Random rand = new Random();
...
:)>-Nice one...I understood your point. I need the other toArray method that specify the return type Cheers!!!!!
p.s. The Set.toArray() returns an Array of Set? (I ask to confirm that I completely...
I want to write a method to print the all the names of a phone book. phoneBook is a HashMap<String, String> , that has names as keys and phone numbers as values.
Reading the documentation for both...
/**
* Returns the busiest hour of the day.
*/
public int busiestHour()
{
int theBusiestHour = 0;
// The hourCounts array has length = 24.
for(int hour...
Going through all the elements of the array I am using a for loop, getting each count every time I loop through the array. how to specify in the loop body which from all the counts is the biggest in...
I am trying to write a method that returns the busiest hour in a logAnalyzer class that read web server data and analyze hourly access patterns and stores them in an array. My problem is, in order...
/**
* Remove from the club's collection all members who
* joined in the given month, and return them stored
* in a seperate collection object.
* @param month The month of the...
Greg Thank you very much for your time and help, I did it finally and I feel soooooo excited...
I see it now and it seems so simple after all... I mean I struggled to find the solution thinking the...
I dont necessarily need to use a while loop to do it. I assumed i did, because the section of the book the exercise is, is introducing the while loop...
The whole point of my problem is how to stop...
Hello
I am trying to improve the method I post below in order to stop the track previously selected before the next starts, so that they dont play simultaneously... I cannot find a way to do so......
gg Off course you are right...I didnt notice that... like that it becomes more straightforward. Thank you very much, so I guess I am in the right way.
So there isnt a real need in this case...
I see... thank you for your time...But how would that possibly work? I will have a problem because the index number of the last entry of my arraylist is always the size of my arraylist minus 1...
Hello
I am a very beginner in java programming and I am trying to learn on my one using the "objects first with java" book. So I would like to know if there are differences between my...