Matthew Jones

Ranch Hand
+ Follow
since Dec 21, 2000
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 Matthew Jones

A Constructor's main purpose is to intialize your object. When you are dealing with non-visual objects, this can be kinda hard to understand, but basically it set's your variables values and allocates memory space for them (not necassarily it that order).
An easier way to see this, is if you create a Java application that has a frame, when you code the object, you would put all of the code dealing with how big your frame is, the layout, the elements in it, and all of that in the contructor. If you are familiar with applets at all, basically everything you would include in init() methond in an applet, you would put in a constructor for an application.
19 years ago
Here's how I do it. I write out the decimal values corresponding to each binary digit:
128 64 32 16 8 4 2 1
Then I take my number, and find the biggest one that would fit, in the example, it was 86, so ti put a 1 under 64:
128 64 32 16 8 4 2 1
0 1
Then subtract 64 from 86, leaving 22, take 22, and put a 1 under 16:
128 64 32 16 8 4 2 1
0 1 0 1
Leaving 6, repeat the process, and you get:
128 64 32 16 8 4 2 1
0 1 0 1 0 1 1 0
And that's the binary for 86.
You can double-check your answer, by adding 64 + 16 + 4 + 2 = 86
There are probably faster ways of doing it, but I think this is the easiest.
Well, I can't get the numbers to line up right, but I think you get the idea.
[This message has been edited by Matthew Jones (edited February 06, 2001).]
19 years ago
It also makes it easier for someone maybe not as familar with the class structure to see where the classes you are using are coming from, if you explicitly name each class in your import statements.
19 years ago
Why would you need to convert Java class files to and .exe file? Why don't you just incluce the JVM when you distribute your app, and keep it a Java app, that way it can be used on any platform, if you decide later you need to be able to run it on other kinds of compuers.
19 years ago
Unfortunatly, you have to write the code to close the window yourself(sort of). I believe that it generates an event when you click on the close button, but you then have to capture it and destroy the window. Not exactly sure how, but one way would be to setVisible(false) and then set the frame equal to null. There may be a better way or a method written already, but I don't know what it is.
19 years ago
I would think so.
Bytecode is bytecode, differnet compliers may be better at optimizing or whatever, but bytecode should pretty much be the same, or you would have to have a different version of the JVM to run it.
19 years ago
Your two lines:

Should read:
19 years ago
You said that the column width will depend on the size of the field, but when you set the constraints, you set the width to 1 for all of the columns.
If you want the width different, you have to change the width when you are setting the constraints. The width is a proportion, so if you set column 1 to width 2, and column 2 to width 1, column 1 would be twice as wide as column 2
19 years ago
When you write, "Pass p = new Pass();", you are calling the Constructor, and the constructor helps in creating a new object.
If you remember, the constructor for Pass is "Pass() { }", which should look a little familiar...
19 years ago
I depends on what you need to do with the variables.
If you want other classes to be able to modify the variables directly, you probably want to declare them public.
If they are used just in the class, you can either not have an access modifier, or declare them private.
19 years ago
I'm not exactly sure why it complies, but I have had the same thing happen with some of my programs, that even though the compliler generated an error, the program still compiles. I would guess it would have do to with the severity of the error. Some errors will make code that is still able to run, although maybe not exactly as intended, while other's would generate unrunnable code.
19 years ago
It would really help if you posted your code. If the applet is compling, your classpath is probably set correctly, but there is probably some minor thing wrong with the code that's causint the problem.
19 years ago
Object declaration is when you declare that you are going to use a variable of a certain type in your program:

Instentiation is when you actually create the object:

When you declare x, you are just saying that you are going to use a variable x of type int.
When you instentiate, you are actually create the object, and assigning values. Even though I used a primitive type, it applies to all objects.
19 years ago
Just because a class is deprecicated doesn't mean you can't use it, it just means that a better way of doing the same thing was developed, and it will give you a depreciation message when you compile, but the code will still work.
19 years ago
I think what Cindy was saying is that you can use the valueOf methond when you are playing with a String and you need the value, but don't want to create a new object to hold it, like this:
19 years ago