The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Problems Compiling Code

Posted by PM on October 30, 2001 at 12:38 PM

To All:

Please paste code into a text editor save it as PressAnyKeyDemo.java and compile it; I'm getting '8' error, why?

Thank you.
PM

import javax.swing.JOptionPane ;
=20
public class PressAnyKeyDemo

{

public static void pressAnyKey()

{

int[] iArray =3D new int [ 1 ] ;

try
{
System.out.print("Press any key to continue.") ; // = print a prompt

iArray[ 0 ] =3D System.in.read() ;
// receive a key = stroke
}

catch( Exception e) // catch an error

{
JOptionPane.showMessageDialog( null,=20
e + " " + e.getMessage() ,
"Caught",
JOptionPane.INFORMATION_MESSAGE ) ;
}
=20
} =20

public static void main ( String args[])

{

System.out.println("Before pressAnykey(). \n") ;

pressAnyKey() ;

System.out.println("\nAfter pressAnykey().") ;

}

} // end class



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us