quick java question

Rallispec

Lifer
Jul 26, 2001
12,375
10
81
how can i get the user to input a variable in java?

the equivilent of an inputbox in Visual basic or Scanf in C


thanks
 

Jzero

Lifer
Oct 10, 1999
18,834
1
0
It's a pain in the ass....you need to use bufferedreader...I think that's the easiest way.
 

Rallispec

Lifer
Jul 26, 2001
12,375
10
81
damn, thats what i was afraid of. thats the only thing i could find in my book.

i'm really beginning to dislike java.


VB for life.
 

911paramedic

Diamond Member
Jan 7, 2002
9,448
1
76


<< damn, thats what i was afraid of. thats the only thing i could find in my book.

i'm really beginning to dislike java.


VB for life.
>>



Great, now you tell me. I have 3 huge java books due here in the morning...
 

TJN23

Golden Member
May 4, 2002
1,670
0
0
you can get a user to input a variable in the form of an integer or a string, the following program will do so: (copy/paste/compile)

import javax.swing.*;
public class inputNumber() {
public static void main( String args[] ) {
String in = JOptionPane.showInputDialog( "Enter a number" );
int input = Integer.parseInt( in );
JOptionPane.showMessageDialog( null, "The number you entered is " + input, "Title of Program", JOptionPane.INFORMATION_MESSAGE );

System.exit( 0 );
}
}

keep in mind that, for the most part, all input in java comes in as a string which will then need to be parsed into an integer, floating point, or some other variable type.

hope that helps

lata

 

Jzero

Lifer
Oct 10, 1999
18,834
1
0
No, don't read it the wrong way Java is really a great language. It's just that for some reason prompting for user input is far more complex than it has to be. Although once you figured out how to work the bufferedreader, it's really quite simple.
Basically, if you can figure out how to interpret and use the API listing at java.sun.com, you can pretty much figure out how to do ANYTHING in Java.

It's just frustrating that with all the great "canned" functions that come built into the API, they couldn't have one simple way to grab user input
 

Rallispec

Lifer
Jul 26, 2001
12,375
10
81
Jzero... yeah, its not all bad, and it looks like it has potential.. but i'm just so used to all the microsoft languages that it is really frustrating.


and what i woudltn do for a decent compiler. BlueJ is killing me. Why cant Visual Studios 6 include java???? AHHH :|
 

charrison

Lifer
Oct 13, 1999
17,033
1
81
Rallispec,

You can get forte off sun.com. It is pretty good java ide, you just need about 512meg of ram installed for it to be usefull.
 

statetech

Senior member
Jun 6, 2001
463
0
0


<< BlueJ is killing me. >>



Seriously? I'm taking a java course and we're using BlueJ as well and I like quite a bit. Do note that java is really the only language I'm learning as of right now and I'm completely new to programming in general.

TJN23, nice coding

Rallispec, if you have further problems, post away and I'll see if my n00b skillz can help.....
.....well, lack of skills can help
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |