James E Baker

+ Follow
since Jul 28, 2011
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 James E Baker

I just visited the tutorial that Campbell suggested and it's pretty good. I would also recommend it.


10 years ago

Sorry, I didn't catch that the two classes were in different packages. That makes more sense.
10 years ago
Welcome to JavaRanch!

First, if Fruit and Apple are in the same package, you don't need to import Fruit.

Second, I copied and pasted your posted code and it ran just fine. See below:

Output : Fruit foo!
10 years ago
Oops! I posted my ideas as a console window program instead of GUI, but you get the idea. You can do the same thing using Swing objects.

10 years ago
To build on Fred's comment, I would say you should make the entire calculator its own class. Then use a do-while as part of your validation so if the user enters an invalid value, it will give the user the opportunity to re-enter the correct values. Then all you are doing in main() is calling on your BMI class. This makes it portable so you can use it with other Java programs...

Once you figure that out, you may want to move the BMI code to the constructor and/or make it static so you don't need to create an instance of BMI. Have fun playing around with it! (forgive any syntax or typing errors... I did this reply quickly)

10 years ago
Silly question, but mySplash.png is inside your jar file, correct?
10 years ago

If you aren't comfortable with main() yet, then you probably are over your head with this code. Try something simple and learn how a class works before playing with the code you have here. Why don't you run this in Eclipse and get a feel for the format of a class.

Have fun!!!
10 years ago
I searched the JDBC forum & Google and found a few discussions but nothing that solved my issues.

I am trying to access a Microsoft Access database file. My code seems to be sound but I am getting the "architecture mismatch" error shown in the subject line.

Access file in .mdb format (32-bit), Eclipse (64-bit) and Windows 7 (64-bit)

I loaded the driver using C:\Windows\SysWOW64\odbcad32.exe and selected Micosoft Access Driver (*.mdb).

I don't think it has anything to do with the code because it's an architecture mismatch but I'll post it anyway if you're curious. I'll leave out the non-related code and catch statements...

... and main()

So, I am stumped! I cannot figure out why I'm getting this error.

Thanks for looking... James

sean slater wrote:

the eclipse says there isnt a main....

When you run something in Java, it looks for the "main" method as a starting point. If you class doesn't have one, it can't be executed unless it's being called by some other code somewhere.

Add this into your class....
10 years ago
I'm not sure what you're looking for. It will be stored in whatever memory location is available. Just like any variable, you can't predict the specific address of the memory block it will be stored in. The location isn't relative to anything else in your code.

Really, once that class is a part of your program, any memory it allocates is just overhead. It's nothing you need to manage.
10 years ago

Greg Brannon wrote:Mr. Burke provided an excellent link for learning Swing, but I recommend you learn to code Swing "by hand" rather than using Netbeans' GUI Builder as suggested there. The GUI Builder generates code that is nearly impossible to read, modify, or maintain.!

I couldn't agree more. You definitely need to do Swing and AWT stuff by hand if you wanna learn it. Alot of people on the forum prefer wring code with at text editor, which does work great. However, it wouldn't hurt to use an IDE to help you with debugging. I like Eclipse which is open source & free.
10 years ago
There are two important things to know.

1. The letters that make up a String are stored within that class as a char array. And, therefore, a String can be convert to a char array.

2. When you have a char such as 'A', it has an integer value. 'A' = 65, 'B' = 66, etc...

It's kind of an unusual situation. Just remember to think of 'A' as 65 thru 'Z' as 90.
10 years ago
Hi Jr....

First... to save you some grief when posting, make sure to use "code" button when posting code on the forum to make it easier to read and reply to.

I'm not 100% sure I know exactly how you want your output to look, but I have four suggestions for you to try.

1. At the beginning, you have the line "int num = 0;" for no apparent reason. It is never used in your code.
2. You have a line "c = OctalNum.charAt(0); " which I think you should change to "c = OctalNum.charAt(i); "
3. What is the "for (j=1; j < c; j++) " about? I would completely delete that from your code. It doesn't seem to serve a purpose and "c" is a char value not an int.
4. Change your output to "System.out.println(n+ " converted to binary is "+ binaryArray[n]); "

Below shows the changes I made....

My output is....

Octal to Binary Conversion
Enter the Octal Number:
0 converted to binary is 000
1 converted to binary is 001
2 converted to binary is 010
3 converted to binary is 011
Do you want to enter another Octal number? Y for yes or N for No:
10 years ago
I don't think there's anything in the code you posted causing any delays. It's pretty basic stuff... just random number generating and switch statements. The only part that I am not sure about is the "doc.add" statement but I doubt that would do it either.

You could always //comment out parts (or all) of the code and then test your servlet.
10 years ago

tim mills wrote:Got the book, which was highly recommended, but it covers java 5. I'm a beginner; is it of any use? Any help is appreciated

Yes. It is definitely of use. If you have no experience with Java and are starting with the basics, there is little (if any) difference.
10 years ago