Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Help! I used too many lines of code. Help me make this more efficient.
- * This main method must create an array with the same four words. Then I
- * have to test each word using the password method. I have to print a
- * message that the password was accepted.
- * @param args
- */
- public static void main(String[] args) {
- String[] words = { "Imagine", "yourself", "on", "Mars" };
- for(int x = 0; x < words.length; x++) {
- if (password(words[x]) == true){
- System.out.println("Password accepted");
- }
- }
- }
- public static boolean password(String w){
- return w.equals("Mars");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement