Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Tony Docherty

+ Follow
since Aug 07, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tony Docherty

Dave Tolls wrote:Sequence does not hav a no-args constructor, so cannot be serialized at all.

You can serialize it using the alternate approach I described in my earlier post provided there are getters and setters for the fields you need to serialize (or you are willing to use reflection).
1 week ago
Not sure why you are saving the state of the object but if you are trying to provide persistent storage then I would advise against using Serializable. if, on the other hand, you are implementing transient storage then Serializable is an acceptable approach, you do need a no args constructor though to deserialise an object.
An alternative approach to extending the Sequence class would be to create a wrapper class which implements the readObject and writeObject methods as stated in the API docs for Serializable. The wrapper class could then handle serialization and deserialization of the Sequence object's state through these methods.
1 week ago
Are you asking how to run the given class from the command line or are you asking how to call the given code from another class?
4 weeks ago
Glad to hear the advice was useful.
1 month ago
Your index into the array is with a variable of type byte. The maximum size of a byte is 127. If you add 1 onto a byte whose value is 127 the value wraps around to the minimum byte value of -128 hence you get an ArrayIndexOutOfBoundsException giving a value of -128.

The solution is to change the type of data to an int.
2 months ago
No it's not a valid solution.

available() returns the number of bytes that can be read without blocking. If it returns 0 it does not mean the end of the stream has been reached it just means there are currently no more bytes available to read. This could be due to i/o delays, network delays etc.

Using available() in this way may appear to work every time when the file is stored locally but there are no guarantees. In short it's extremely bad practice to do this.
3 months ago
All classes have an equals() method but the String class also has an equalsIgnoreCase() method which is useful when you want to compare strings for equality ignoring the case of the letters.
3 months ago
Is there a specific reason you need to know this?
One of the good things about Java is all memory allocations are handled for you and for 99.999% of cases you don't need to worry (or even know) where variables are stored. And no there are no special instructions relating to their storage.
3 months ago

Caiz Austin wrote:
At the moment I would create a Briefcase class and initialise 26 Briefcases as an array setting each individual briefcase a value e.g. briefcase[0] = 0.50; briefcase[1] = 1.

That's not implementing a Briefcase class, that's having a float (or double) array called briefcase.
If you do implement a Briefcase class it can have properties such as value, opened etc. You could then have an array of type Briefcase which you filled with Briefcase instances ie briefcase[0] = new Briefcase(0.5, false);
3 months ago
Ok so now you know the code works it's just the connection details to the university DB that you need to sort out.
3 months ago

Ray Bell wrote:I meant a different forum on coderanch..

OK, please can you provide a link to the other thread so we are not repeating ourselves.
3 months ago
The code in Oracle_select3 has different connection details to the code in Oracle_select4 so when you checked the details as per your earlier post were you checking the details in Oracle_select3 or in Oracle_select4?
3 months ago

Ray Bell wrote:I checked the connection in tnsnames.ora as suggested in a similar discussion. It seems to match.

What do you mean by in a similar discussion - have you posted this question on other site(s)? We don't mind if you cross post but as we all give up our time here for free we would rather not waste it answering a question that has already been answered elsewhere, so please let us know where else it is posted so we can check on what answers have already been given.

And what does "it seems to match" mean - You can either establish a connection or you can't. Have you physically established a connection or are you just looking at the logon data in the code and checking it looks the same as the data you have been given.
3 months ago
No that's still the stack trace for Oracle_select3
3 months ago