0

i'm making a simple program that will accept 7 input using JOptionPane
i'm found out that JOptionPane has been used 7 times i want to transform in function i make it but i encounter an error.

import javax.swing.JOptionPane;

public class SevenWord2A{

public static void main() throws NoSuchMethodError 
{
String word1="";
String word2="";
String word3="";
String word4="";
String word5="";
String word6="";
String word7="";

getWord();

String msg = word1 + " " + word2 + " " + word3 + " " + word4 + " " + word5 + " " + word6 + " " + word7;
JOptionPane.showMessageDialog(null, msg);
}

String Function getWord(){

  JOptionPane.showInputDialog("Enter Word");
  
}
}

and this is the error


java.lang.NoSuchMethodError: main
Exception in thread "main"

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by stultuske
0

First of all don't put a 'throws' at the main.
Second of all the error is very easy to figure out. Check your notes on how to write and run a simple program.

0

First of all don't put a 'throws' at the main.
Second of all the error is very easy to figure out. Check your notes on how to write and run a simple program.

agree with javaAddict:
just another remark:
either make the getWord() method static, or call it from an instance of SevenWords2a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.