1

Help with my code?

clock lord's Avatar clock lord8/29/12 1:06 pm
1 emeralds 52
NOTE THAT THIS IS NOT MINECRAFT MOD CODE!
Ok so I am a newbie at java and I wanted to make a simple password program, but everytime I run my code nomatter what it denies me, even if I type the right password.
Heres its code:

MAIN CLASS/METHOD:


import java.util.Scanner;
public class Mainclass {

public static void main(String[] args) {
System.out.println("What is the password?");
Scanner pass = new Scanner(System.in);
String x = pass.nextLine();
Pro ProObject = new Pro();
ProObject.beg(x);



}
}


2ND CLASS/METHOD:


import java.util.Scanner;
public class Pro {

public static void beg(String x) {
if (x == "password"){
System.out.println("Access granted");
}else{
System.out.println("Access denied");
Scanner y = new Scanner(System.in);
System.out.println("Press <Enter> to close");
System.out.println(y.nextLine());
}

}

}

Help?
Posted by clock lord's Avatar
clock lord
Level 11 : Journeyman Network
3

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome