Search:

Type: Posts; User: bihlas

Search: Search took 0.42 seconds.

  1. [SOLVED] Re: How do I sort a TreeSet by Person's age?

    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...
  2. [SOLVED] How do I sort a TreeSet by Person's age?

    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...
  3. Re: Why don't I get all the elements in my TreeSet?

    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...
  4. Why don't I get all the elements in my TreeSet?

    public void createPersons()
    {
    Random rand = new Random();
    for(int index = 0; index < persons.length; index++) {
    Person person = new Person(rand.nextInt(maxAge),...
  5. why the command prompt does not recognize java as a command?

    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...
  6. Re: how to ensure that my method wont return the same random number twice in a row

    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...
  7. Re: how to ensure that my method wont return the same random number twice in a row

    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...
  8. Re: how to ensure that my method wont return the same random number twice in a row

    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...
  9. Re: how to ensure that my method wont return the same random number twice in a row

    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...
  10. how to ensure that my method wont return the same random number twice in a row

    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();
    ...
  11. Re: How to print out all keys cerrently stored in a HashMap?

    :)>-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...
  12. How to print out all keys cerrently stored in a HashMap?

    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...
  13. Re: How to get the highest value of an array of integers?

    /**
    * Returns the busiest hour of the day.
    */
    public int busiestHour()
    {
    int theBusiestHour = 0;
    // The hourCounts array has length = 24.
    for(int hour...
  14. Re: How to get the highest value of an array of integers?

    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...
  15. How to get the highest value of an array of integers?

    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...
  16. Replies
    5
    Views
    61

    What's wrong with my method?

    /**
    * 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...
  17. Replies
    4
    Views
    60

    Re: How to improve this method?

    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...
  18. Replies
    4
    Views
    60

    Re: How to improve this method?

    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...
  19. Replies
    4
    Views
    60

    How to improve this method?

    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......
  20. Re: Is there any significant difference between these segments of code?

    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...
  21. Re: Is there any significant difference between these segments of code?

    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...
  22. Is there any significant difference between these segments of code?

    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...
Results 1 to 22 of 22