my dog learned polymorphism*
The moose likes Beginning Java and the fly likes New to Board & Questions about 2 .java errs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "New to Board & Questions about 2 .java errs" Watch "New to Board & Questions about 2 .java errs" New topic
Author

New to Board & Questions about 2 .java errs

Sue Elvins
Greenhorn

Joined: Apr 04, 2006
Posts: 1
Hello all,

Let me first say I am just thrilled beyond no other beginning programmer's dream to find this forum! I had actually heard about this place when reading a the O'Reily's book "Head Start Java". I came across a section that mentioned the URL that had beem mentioned and had marked it down for a future visit. I can't recall the last name but I remember the first name was Kathy, sounded like a really sweet lady (and smart too!) from the description. Anyway.

I am a full time college student currently attending a beginners class in JAVA. As good as the class is, I'm not fully grasping certain concepts and that's frustrating to say the least. I've reached a point where I would like some solid feedback on where the improvements and my mistakes are being made rather than hearing this is wrong this is wrong, etc. I have to say when I started reading this reference book that directed me here it was the first time when I didn't feel totally useless or helpless if that makes sense. I'm a UNIX programmer by trade but to in my mind JAVA is like a cup of hot coffee right now. LOL! It's just a matter of breaking through that mental block first you know?

Ok, now to my questions. I'm currently working on a loop applet; the intent is for the user to enter a number 10 times. The number that is entered by the user is then displayed on the screen. EX: "You have entered: " When the user has entered 10 numbers, the highest number will then be shown to the user. EX: "The highest number is: "

Now I am showing 2 errors. I will be using 3 variables within the script. Now they all need to be declared at the beginning of the .java file correct?
For example...
public class Largest
{
// initializing variables in declarations
int counter = 1; // number counter
int number = 0; // number attempts entered
int largest; // result from user

// process 10 using counter controlled loop
while ( counter != 10 ) {

what I sort of understand is the if, else, while statement. But what I don't understand is don't you have to claim what is happening before you can clame the if else statement? Does that make sense or am I confusing myself??

I'll stop with my questions there so I don't get ahead of myself or get any more confused. Sorry so long but it's really good to be here and I look forward to chatting with everyone!

Sue


If it isn't broke, don't fix it.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Welcome to JavaRanch!

Kathy Sierra is indeed real nice. And purty. And so is her husband Bert. He's also nice, too, sometimes.

You asked if all the variables need to be declared at the top of "the script". In C, variables have to be declared at the top of a function, but that's not true in Java. In Java, you can just declare a variable right when you're gonna use it. That's often a good idea -- that big clump of declarations at the top of a function is just a hard to read mess, usually.

Now, about the if/else/before/after question: I think you are, in fact, just confusing yourself, because you sure are confusing me! If'n you want to spell your questions out a bit more, I'd be glad to help you untangle it, but as it stands, I don't know what you're getting at there.

Now, one more super important thing: real code that does sumpin' always goes inside a method, whether it's a public static void main(String[] argv) or something else. You've shown the start of a "while" loop outside of any method, and the compiler ain't gonna cotton to that, nohow.

Y'all come back real soon now, y'hear?


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to Board & Questions about 2 .java errs
 
Similar Threads
Integer.toString.......
Number calculations
Program Problem
So far...
input number to array --not displaying right item [code included]