1 Replies - 960 Views - Last Post: 13 July 2012 - 07:55 PM Rate Topic: -----

#1 adnan18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-July 12

password

Posted 13 July 2012 - 07:48 PM

import javax.swing.JOptionPane;

public class password {


    public static void main (String[] args) 
    	{
 
 String output;
 String	output2;
 String pass2;
 String pass1;
 String passko;
 [code]passko=adnan;
 
 
 pass2=JOptionPane.showInputDialog("enter password to continue(letter only)");
 
 password.compareTO(pass2);
 	if(passko==pass2)
 	{
 		output=("acces Granted");
 		
 		JOptionPane.showMessageDialog(null,output,"welcome",
 										JOptionPane.INFORMATION_MESSAGE);
 	}
 else
 {

 	output2=("acces denied");
 	JOptionPane.showMessageDialog(null,output2,"error",
 										JOptionPane.ERROR_MESSAGE);
 										
 }
 System.exit(0);
 										
 
 
		
    	}
}


Quote



/**
* there is an error message of
*
*
* error: cannot find symbol
* error: cannot find symbol
*/

Is This A Good Question/Topic? 0
  • +

Replies To: password

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8065
  • View blog
  • Posts: 31,308
  • Joined: 06-March 08

Re: password

Posted 13 July 2012 - 07:55 PM

It is compareTo not compareTO

password is your class name (Not a good idea, by concentions, class name should start by a capital letter so your class should be Password)

even if password was a String and you password.compareTo(...
you do not store the result of that comparaison in a int or do a if() on it so the statement is useless

if(passko==pass2)

you cannot compare String using the == operator. You should use the equals() method (or compareTo() and test if it returns 0)

This post has been edited by pbl: 13 July 2012 - 07:56 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1