Quick Java syntax question - combining these two statements?

Status
Not open for further replies.

Zeus

Ars Legatus Legionis
17,285
Subscriptor++
I know these two statements can be combined into one, but I can't find the exact syntax to make it work and make it "legal" by Java's Nazi syntax rules..
code:<HR>
Code:
strVariable = JOptionPane.showInputDialog ("user input");
intVariable = Integer.parseInt (strVariable);

I have many instances of this in a couple of my programs, and I am trying to "clean things up" as best I can.

I can't seem to find it in my textbooks, and my lame attempts generate the usual list of errors when I try to compile. Anybody remember off the top of their head?
 

Zeus

Ars Legatus Legionis
17,285
Subscriptor++
I was about to list the errors that I get from trying to compile that exact line (tried it 4 times, swearing it had to be right each time) when I realized that I had one too many parentheses.

Zeus == brain-fried

Yes, that does work

No, it's not so much to speed up execution, but to cut down on my typing a little. I have numerous calculations that I need to accomplish with user-inputs, and I have typed versions of these two lines a few hundred times now.

Let this be a lesson children:
Don't try to code during the 2am "giddy from lack of sleep" phase!
 
Status
Not open for further replies.