import statement: import statement is similar to the #include statement in C. Using the import statements, we can access to classes that are part of other packages.
Example: import javax.swing.JOptionPane;
This statement instructs that the interpreter to load the JOptionPane class contained in the javax.swing package.
Example:
import javax.swing.JOptionPane;
class ch
{
public static void main(String[] args)
{
String sn1;
int x;
sn1=JOptionPane.showInputDialog("Enter x value");
x=Integer.parseInt(sn1);
JOptionPane.showMessageDialog(null,"value="+x,"output",JOptionPane.ERROR_MESSAGE);}
}
No comments:
Post a Comment