Daniel Hyslop

Greenhorn
+ Follow
since Dec 08, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Hyslop

Thanks guys . Used Campbell's solution and it now works fine. Didn`t realize the argument had to be passed on the command line. The book is the latest 5th edition in "Java easy steps" series of books.
6 years ago
I have just returned to java and coding after being sometime away from it. I have bought a book " Java in easy steps" and have come across a problem where the code I`m asked to enter compiles ok
but when ran it throws an arrayoutoffbounds exception error. I know it`s not me as I`ve cut and pasted the code from the books web site and I get the same error from that code.
The chapter this code comes from is " Passing an argument". Can anyone see what I`m missing,
Please.
6 years ago
thanks guys for the help. The problem was staring me in the face.In the code I have posted the elements in the String array were being filled correctly. I just had the wrong println statment outside the while loop.I was printing a single line of the String array using the outer for loop as a counter which was printing the empty elements and not the elements that were being incremented by "current" if I printed Array[current] then I get the elements being filled and if I use a for loop in the same position using the outer loop as a counter then it fills as well.
I have written pseudo code and planned programs with single classes but find it difficult to adapt them when multiple classes are being used. Would someone be kind enough to explain how to go about planning a program with multiple classes
17 years ago
hi nikki and lynne thanks for the help,I may have missled you on the question I know it really doesn`t matter which element the object is placed in as each object will be identical.What I am trying to do though is place eachobject in the correct elememnt partaining to the int array numbers ie if the numbers in the int array were - {2,4,2,5,4} the first object needs to placed in element 2 of the String array then 4 in element 4 next number is 2 , second element is taken so add one place string object in element three fourth is five -is = to array size so 5=0 place object in 0 if empty and so on I have a pseudo code written for the exercise, but putting the above program to work leaves some of the elements empty.I can`t figure out why these elements don`t get filled
17 years ago
just to add I have changed the class names so a i =new a (), should read
method i = new method();
17 years ago
I am trying to fill an string array 0f five elements with new string objects
using an array of defined ints as index`s at where to place the next String object.I have a for loop to iterate through the array of ints and a while loop for the purpose of placing the the object in the correct position. I find it difficult sometimes to understand how to implement while loops and if statements in the correct logical way.perhaps someone could help me understand better.here`s the code,it compiles and runs as the numbers in the int array stand at the moment, but the string array is left with empty elements
17 years ago
The array that i am creating must be of book1 type.I want to create the objects in the book class.each object must have a title assigned to it ,then it has to be printed to screen.I am unsure how to get the book1 objects in the array to hold the title of the books that I will eventually pass to them.
17 years ago
thanks for your reply henry, I do realise that they are set to null at the moment (sorry I should have said that earlier) .What is confusing me is how do you set what is an book1 object to save a title ;
ie if the method in book1 was declared as public String getTitle()and title was declared as String and you tryed to save it into a book1 object you get a found string expected book1,how do I get around this problem . I want the title of the book to be saved in the the array even though they are going to be all the same at the moment just getting them in the array would be a start . thanks
17 years ago
I am trying to save book1 objects into an array of book1 instances within the book class and would like to save the titles of the books in the array. I wonder if someone could explain to me how you associate what is inherently a string to a book1 object
17 years ago
correct ,the aim of the program is to end up with an array of Employee objects in employeeSort ,sorted according to hashIndex == element
if the element == full then hashIndex +1.the final outcome requires an output from the mainProgram
17 years ago
I have a program with three classes the first `Employee class` introduces a hashIndex calculated from empName the second `EmployeeSort` takes the hashIndex and places the employee class instance into an array of which will be eventually be Employee class objects.I have the Last class passing the name and job using the JOptionPane unfortunately each pass overwrites the last entry in EmployeeSort .Could anyone point me to what I am doing wrong in the program.Heres the code
17 years ago
In a program I have to create a MyClass class a HisClass class and also a main program class which generates output.in MyClass there are names passed to it from the main class using the JOptionPane,24 in all .In the HisClass I have to create an array of MyClass objects and assign each object it`s individual value ie the name passed to the MyClass class.I have all but finnished the program but am at a loss as to how to assign the name values to the array. I wonder if someone could point me in the deirection of some text on this subject on the net or give an explanation on passing USERDEFINED objects between classes.
Thanks in advance
17 years ago
thanks david,
The main main method in this class is not the one that I m using to store the values.The values are called from another class . Name and Course have been concanated and the hash is not random.It is generated in another class from a hashing algorithm using the name object.Just couldn`t figure out why I was getting individual entries.
thanks again for the help
17 years ago
This is not the finnished article as the validity test only checks for matches within the for loop at the moment .It works from another class where the has is worked out but I have added a main method at the bottom to show what should be happening.Here`s the code
17 years ago
I am trying to fill an array with String objects using a for loop.Thestring objects are assigned a hash code(has been change to int value).The hash has to to be matched with an element within an array When I pass this hash through a set of if statements to check it`s validity and save it to one of the elements within the array when the loop completes its first iteration it loses the info saved and I end up just saving one String each Iteration.I wonder if someone could shed some light on how I overcome this
17 years ago