Matt Moran

Greenhorn
+ Follow
since Mar 12, 2005
Matt likes ...
Mac Eclipse IDE Java
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Moran

If you start now, and you spend all day every day on it, you will never be done learning Java.
You'll get good at it of course, and some areas you'll master, but it is a vast, vast subject with more & more APIs appearing daily. You will have embarked upon an adventure that will never end, as long as you do not give up. It's kinda like if you'd asked "If I spend all day every day learning Physics, how long will it take to learn everything?" - the boundary shifts as you approach it, and if you're very good, you get to expand the boundary yourself.
7 years ago
Why? Well, a lot of the "why" of java is down to arbitrary decisions taken by those who decide Java's rules. That said, you can subclass an abstract class that has instance variables that are mutable. Interfaces are supposed to be clean & free of any actual code, just a promise to implement certain methods. You might as easily ask why they can have constants on them.
13 years ago

Cheryl Scodario wrote:

Matt Moran wrote:When you use Array [50] you're just creating an array of Array objects, each containing an array of null objects (the values field of each).



Note you use the bracket [50], but in the code, it's just ( ), like any other objects we have seen before. So I don't think it means array.



Ah, you're right - was posting from my mobile phone: the mobile version of this site doesn't include the thread on the page when you reply - my bad!
13 years ago
When you use Array [50] you're just creating an array of Array objects, each containing an array of null objects (the values field of each).
13 years ago
Yeah, pretty much - I'm assuming here but I think the main purpose of the Array class you have there is to provide a container for other classes (possibly including more arrays if you want a 2D array). The Array class can act upon the Objects it contains assuming a suitable method is created (e.g. a sort method) but you wouldn't expect the Objects to act upon the Array as a whole since you'd expect them to be usable singly. Since Array is a subclass of Object, you *can* hold more Arrays but you're not forced to. They could be Dogs or JButtons or whatever you like. When you want them to act as Dogs etc you need to cast them back to their original classes, so e.g. if we had a Motorbike in values[2] & you wanted to rev its engine, it wouldn't be myArray.values[2].rev(), but rather myBike = (Motorbike)myArray.values[2]; myBike.rev(); - you have to cast it to access methods that aren't available on Object.
13 years ago
1. OK - complex set of questions here, but essentially what your code does is describe a class called Array which has a field that holds an Object array, a field to hold the count of the contents of this Object array, and a flag to indicate whether it's sorted or not. You use an Object array because every object in Java is an instance of the class Object or its subclasses, so you can refer to anything as an Object & therefore an Object[] array can hold all sorts of things. An Array of Array objects would only be able to hold Arrays, which gets mind-bogglingly recursive but not very useful unless all you'll ever deal with are Arrays.

As the code stands, since the Array class doesn't have a handy toString() method that iterates through it printing out the contents of the values field, you'd get a weird looking reference to your Array object rather than anything helpful.

2. Array indexes start at 0 so the 2nd element is index 1. If I remember rightly you can't do the operation you're after using one single array - you'd be better off creating a new array of size max+1 as a temporary variable, copying your values over as needed & returning it as if it were the parameter array.
13 years ago
Ah - thanks! Yes, it seems the person who used to use this PC used the CVS plugin with their Eclipse, whereas we don't have it set up on my old one. Thanks :-)
Hi,

I'm fairly new at using Eclipse & I just came across this for the first time, googled it & couldn't find diddly about it, so I was wondering if anyone here might know what this is:
In my Eclipse package explorer, I have a couple of projects freshly checked out of CVS. Previously the project names have appeared normal but now they have a > sign before them, and a server's hostname in square brackets after, like this:

> MyProject [SomeServer]

Why is this? What's caused it & what does it mean?

The server is the one we use for CVS hosting - I don't know if that's a relevant detail or not.
1.4 - we're on 1.3 at work, and I've been reading the 1.4 edition of the K&B book for the past year or so. I may upgrade later if we upgrade our Java.
Bah! I ordered the book anyway & had it delivered today. The CD does indeed seem rather pants but the book itself is pure gold.
I'd like to see a book in the Head First style that deals with more in-depth intermediate to advanced J2SE topics, like how to put together the stuff learned from HFJ, when to use composition as opposed to inheritance, how best to decide on access levels when designing classes, with more exercises based on real-world programming tasks you're likely to come across. And maybe more in the way of "What's wrong with this code" type exercises where maybe the code compiles and runs, and it looks alright, but you get something unexpected from it. And definitely more in the way of Swing tutorials - like what Kathy & Bert did with the Box and Border layouts in HFJ, only with Gridbag & trying to model common app layouts with that accurately so that the app doesn't look like a dog's dinner when you resize it.



I'm just getting to the end of HFJ now, and I'm quite hungry for more - what would people recommend as the next step?
19 years ago
Joyce - I take it the mock exam on the K&B CD is written in Java, & will run anywhere with a compatible JRE?

(Just making sure - I don't have a Windows or MacOS box at home, just Linux)
Thanks Eric - much appreciated!
19 years ago
On the Javaranch radio RSS feed which I've set up in Livejournal so it feeds into my friends page, whenever one of you posts a code snippet in <pre> tags, you put a style specification for the background colour so that the background is in silver. However, you don't specify a colour for the text itself, so when viewed on my LJ friends page where the style is silver on black, all I get is a big block of silver unless I highlight the code with my mouse. Since your background style spec is overriding mine, there's nothing I can really do about it. Could you put in a quick color:black along with the background:silver in your blogs' stylesheets for <pre> please?
19 years ago