aspose file tools*
The moose likes Beginning Java and the fly likes String variables and Int variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String variables and Int variables" Watch "String variables and Int variables" New topic
Author

String variables and Int variables

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
how do i write a string variable and an int variable?
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
1234
JavaRanch rocks
JavaRanch rocks 1234 days a year


IBM 286, SCJP, SCWCD, EIEIO
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
Hey Rick! You sound like someone that could really help me out. I have been trying to figure this code out for like a week. i am new to java and i was told i need string variables and int variables to make a code work were i had two different users that will input data i.e. first name, last name, and age so six dialog boxes will pop up. then in the end i need to compare the ages and make the last dialog box say something like this:

First Person: Smith, John (31)
Second Person: Doe, Mike (35)
Doe is older than Smith


Here is my code: if you can let me know what i need to chang where you would be my ideal im so confused!!

Code:
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
if anyone else sees this i would appreciate your help as well. i think im about like anne in the thread below mine...just confused and trying to learn. thats why i have so many posts pretty much about the samething! so sorry about that, but i appreciate everything!! you guys are awesome!!
Dan Walin
Ranch Hand

Joined: Nov 11, 2003
Posts: 109
A big problem I see is that you're using the same variable name for the int and the String.
You must be getting a compiler error.
Try this:
The same problem exists with "age2" also. Be sure to update the rest of the code to match. The "parseInt" method takes the string "s_age1" and converts it to an int "i_age1". I see another typing error: You have "Intger.parseInt()" and it should be "Integer.parseInt()".

Those are the first few things I see.
[ September 10, 2004: Message edited by: Dan Walin ]
Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
so since this is for two different "users" to enter info and be compared do i need to some how show that there are two users? i dont understand that part either.
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
You are pretty close. I think you want something like this:When you defined the age2 variable, you defined it as a "string", but it should be "String" (with a capital S). Also, your variable called "message" wasn't defined, so I had to add this line: String message = "";

There are lots of other ways to snazz that program up if you wanted to. For example, instead of doing this:You can do this:
Hope that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String variables and Int variables