Hi Shawn,
I had the same error.  I got rid of it by including a package statement,
eg.:

package myassignment;

The first statement in a java file (excluding comments) should be the
package declaration.  However, the package declaration is optional AFAIK.
 So I'm not entirely sure why netbeans is complaining when it is absent.

On Sat, Jul 11, 2009 at 15:45, Shawn Sampson <[email protected]> wrote:

>
> // does anyone know why I am getting this error?
>
>
> import javax.swing.JOptionPane;  // Error is here states "incorrect
> package"  the program still
>                                                 //works correctly
>
> public class MyOwnWhileProject {
>
>    /** Creates a new instance of ForLoop */
>    public MyOwnWhileProject() {
>    }
>
>    /**
>     * @param args the command line arguments
>     */
>    public static void main(String[] args) {
>        // Declare and initialize String array variable called names.
>        String names []=
> {"Beah","Bianca","Lance","Belle","Nico","Yza","Gem","Ethan"};
>
>        // This is the search string we are going to use to search the
> array.
>        String searchName = JOptionPane.showInputDialog("Enter either
> \"Yza\" or \"noname\"!");
>
>        // declare int i
>        int i=0;
>
>        // Declare and initialize boolean primitive type variable
> calld foundName.
>        boolean foundName = false;
>
>
>        // Search the String array using for loop.
>        //  * The "names.length" is the size of the array.
>        //  * This for loop compares the value of each entry of the
> array with
>        //     the value of searchString String type variable.
>        //  * The equals(..) is a method of String class. Think about
> why you
>        //     cannot use "names[i] == searchName" as comparison logic
> here.
>
>        while ( i<names.length) {
>
>            if (names [i].equals(searchName)) {
>                foundName =true;
>
>            }
>            i++;
>
>        }
>
>        // Display the result
>        if (foundName)
>            JOptionPane.showMessageDialog(null, searchName + " is
> found!");
>        else
>            JOptionPane.showMessageDialog(null, searchName + " is not
> found!");
>
>    }
>
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to