Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-04-2012, 06:27 PM   PM User | #1
dannyboi
New Coder

 
Join Date: Jul 2012
Location: NYC
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
dannyboi is an unknown quantity at this point
Need help with this code?

Quote:
package HelloApp;

import java.util.Scanner;



public class Main {


static Scanner sc = new Scanner (System.in);

public static void main(String[] args) {
{

JOptionPane.showMessageDialog(null, "Enter an integer:");
int x= sc.nextInt();
JOptionPane.showMessageDialog(null, "You entered" + x + ".");
}
Keeps saying I'm missing a bracket, i correct it but the problem persists.
dannyboi is offline   Reply With Quote
Old 08-04-2012, 09:26 PM   PM User | #2
RodionGork
New Coder

 
Join Date: Mar 2012
Posts: 24
Thanks: 0
Thanked 3 Times in 3 Posts
RodionGork is an unknown quantity at this point
Quote:
Keeps saying I'm missing a bracket
Here is 3 opening curly brackets and only 1 closing. You really think it is normal?
RodionGork is offline   Reply With Quote
Old 08-05-2012, 11:59 PM   PM User | #3
dannyboi
New Coder

 
Join Date: Jul 2012
Location: NYC
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
dannyboi is an unknown quantity at this point
OK, besides that...
dannyboi is offline   Reply With Quote
Old 08-06-2012, 04:13 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by dannyboi View Post
OK, besides that...
I don't understand this followup question. That is literally all that is wrong with it. Make sure you add the missing closing braces. Just the class and the method itself; I'd remove the redundant open and close braces as well though.

Now other than this, you are mixing swing and command line components. This is bizarre to say the least, if you want to use a gui, then keep it all in the gui. Use the showInputDialog instead and try/catch an Integer.parseInt call. Otherwise, even packed as a jar you'd need to execute it on the command line every time in order to receive input.
Fou-Lu is offline   Reply With Quote
Old 08-06-2012, 10:46 AM   PM User | #5
pawpoint
New Coder

 
Join Date: Feb 2012
Location: uk
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
pawpoint is an unknown quantity at this point
Just follow the rule that for every open bracket, you need a closed bracket. Code needs to balance
__________________
Dog Clothes
pawpoint is offline   Reply With Quote
Reply

Bookmarks

Tags
java, java programming

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:22 AM.


Advertisement
Log in to turn off these ads.