Colin Kenworthy

Ranch Hand
+ Follow
since Aug 06, 2001
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Colin Kenworthy

... and I know int is a type of Integer

int and Integer are not related, one is a primitive and the other is an Object.
17 years ago
Rather than write "if <a condition> is true then return true, otherwise return false" why not just return <a condition> ? As in:

or even just

19 years ago
I've just got ant 1.4 running - these are my settings:
OS = WinNT
Ant v1.4 installed in C:\jakarta-ant-1.4
JDK v1.3 installed in C:\jdk1.3.0_02
JBoss has some Ant instructions and a small test you can run to check Ant is working.
19 years ago
I can install BDK 1.1 quite happily with the 1.3 SDK installed.
As soon as I install the 1.4 SDK (not beta anymore!) then BDK 1.1 becomes impossible to install.
When I remove 1.4 and reinstall the 1.3 SDK again then the BDK 1.1 will happily install once more.
Before you ask - yes I am setting up the PATH variable correctly each time.
Is there an incompatibility between BDK 1.1 and SDK 1.4.0 ? It would seem as if there is.
[ March 25, 2002: Message edited by: Colin Kenworthy ]
19 years ago

Originally posted by Andrew Parker:
Any method that throws a checked exception must be called within a try clause, or the method must declare that it throws the exception(Don't understand here!).

Basically the above says that you MUST do something with the exception if it is raised. The exception can be dealt with in a catch block or if you don't want to deal with it you must declare that you will throw the exception back up the method calling chain.
If you throw the exception, then now everything that calls your method needs to do it within a try/catch block!
See for how to use bold and formatting code examples.
The final catcher for exceptions is the JVM. You will see this when you get a run time exception.
20 years ago
An idea might be to do this in reverse by putting the text onto the Graphics and copying the Graphics into your canvas.
Use drawString() or drawChars() on the Graphics object.
The BufferedImage class gives you a getRGB(int x, int y) method.
The problem is how to get a BufferedImage object from your Graphics object. I can't solve that one - anyone else suggest a way ?
The other option is to code all possible characters into your paint method.
Save as JPEG:
Can't be done in J2SE 1.3. It needs helper classes.
20 years ago
"public class Manager extends Employee "
Here you state that the class Manager is a subclass of class Employee. Or, to put it another way, class Employee is the superclass of class Manager. It is perfectly legitimate to define a variable of one class and assign to it an object of that class OR a subclass of it.
e.g. Object o = new Employee(); (Object is the superclass of all classes)
e.g. Employee empl = new Manager();
As Manager is a subclass of Employee it inherits all of Employee's methods and attributes and then adds some of it's own.
Anything you can do to an Employee object you can do to a Manager object.
As far as the compiler is concerned whenever you reference variable empl you are referencing an Employee object. If you want to use the Manager's methods or attributes you need to cast the variable empl to class Manager.
e.g. empl.upBonus(); will not work - upBonus is not a method in class Employee
e.g. ((Manager)empl).upBonus(); compiler accepts this.
Any 'teach yourself..' book and the java tutorial
will teach you this. Don't try to run before you can walk!
20 years ago
You can use overloaded methods like this.
To borrow the above example:

Here you supply default value 2 as the second int when the method is called with just one int parameter.
This way you have all the code in just 1 method.
20 years ago
A Singleton design would guarantee just one instance of the class.
A class with only static methods could be instantiated many times (pointless I admit, but possible all the same).
20 years ago
Yes, length is not a method but a property of arrays so you just need to drop the '()'.
20 years ago
Download the Java API documentation - you'll find everything you need to know in there!
20 years ago
Learn the difference between char and Character.
Learn the difference between a primitive type and an Object.
...then you should understand what's going on.
20 years ago
Abstract classes can generally provide what you would consider 'logical' inheritance.
e.g. vehicle > car or mammal > dog
Interfaces can provide links between hugely dissimilar classes.
e.g. in a drawing application an interface Drawable might be implemented by classes such as Triangle, EarthMover and Fish.
20 years ago
Continue doesn't mean "continue with the next statement", in this case it means go back to the for loop end execute the next iteration through it. So basically you only print something if i != j. If i == j you repeat the inner loop.
It's as if you had labelled the innermost for loop 'inner:' and your statement was 'continue inner;'.
20 years ago