Click here to Skip to main content
15,914,221 members
Home / Discussions / Java
   

Java

 
GeneralRe: demende d'aide Pin
Richard MacCutchan6-Mar-13 0:39
mveRichard MacCutchan6-Mar-13 0:39 
GeneralRe: demende d'aide Pin
dusty_dex6-Mar-13 4:43
dusty_dex6-Mar-13 4:43 
Questionjava Pin
javed alm4-Mar-13 18:38
javed alm4-Mar-13 18:38 
AnswerRe: java Pin
Richard MacCutchan4-Mar-13 23:19
mveRichard MacCutchan4-Mar-13 23:19 
QuestionJava Server read txt file and compare to data in Excel file. Pin
EuphorialXTC4-Mar-13 8:49
EuphorialXTC4-Mar-13 8:49 
AnswerRe: Java Server read txt file and compare to data in Excel file. Pin
Richard MacCutchan4-Mar-13 23:18
mveRichard MacCutchan4-Mar-13 23:18 
GeneralRe: Java Server read txt file and compare to data in Excel file. Pin
EuphorialXTC4-Mar-13 23:22
EuphorialXTC4-Mar-13 23:22 
Questionandroid app Pin
StudentGirl3-Mar-13 19:36
StudentGirl3-Mar-13 19:36 
AnswerRe: android app Pin
Sandeep Mewara3-Mar-13 20:13
mveSandeep Mewara3-Mar-13 20:13 
GeneralRe: android app Pin
StudentGirl5-Mar-13 4:03
StudentGirl5-Mar-13 4:03 
QuestionHow to manipulate a combo box? Pin
Member 98295361-Mar-13 23:28
Member 98295361-Mar-13 23:28 
AnswerRe: How to manipulate a combo box? Pin
Richard MacCutchan1-Mar-13 23:59
mveRichard MacCutchan1-Mar-13 23:59 
QuestionImage Mosaicing Pin
rachit1328-Feb-13 19:03
rachit1328-Feb-13 19:03 
QuestionCan we have Scala added to the list? Pin
dusty_dex26-Feb-13 6:48
dusty_dex26-Feb-13 6:48 
AnswerRe: Can we have Scala added to the list? Pin
jschell26-Feb-13 9:04
jschell26-Feb-13 9:04 
GeneralRe: Can we have Scala added to the list? Pin
dusty_dex26-Feb-13 9:42
dusty_dex26-Feb-13 9:42 
Questionchoise of framework for end of study Pin
simontifo25-Feb-13 2:33
simontifo25-Feb-13 2:33 
AnswerRe: choise of framework for end of study Pin
Prasad Khandekar2-May-13 20:15
professionalPrasad Khandekar2-May-13 20:15 
Questioncompiler Pin
Olfat Ameen 23-Feb-13 17:56
Olfat Ameen 23-Feb-13 17:56 
AnswerRe: compiler Pin
Richard MacCutchan23-Feb-13 21:18
mveRichard MacCutchan23-Feb-13 21:18 
QuestionJava Pin
thevivek.pro21-Feb-13 19:42
thevivek.pro21-Feb-13 19:42 
AnswerRe: Java Pin
Marco Bertschi21-Feb-13 22:08
protectorMarco Bertschi21-Feb-13 22:08 
Questionproblem with looping Pin
Member 982953620-Feb-13 22:20
Member 982953620-Feb-13 22:20 
Hello everyone! I'm currently having a problem with my program it doesn't loop properly please help me with it. The code is below. Thanks in advance!

Java
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.*;
    public class Wewe{
        public static void main(String[]args){
            Scanner inp = new Scanner(System.in);
            boolean tryAgain;
            do{
            System.out.print("\nInput username: ");
            String user = inp.nextLine();
            System.out.print("\nInput password: ");
            String pass = inp.nextLine();
        if(user.equals("admin") && pass.equals("admin")){
                System.out.print("Success!");
                tryAgain = true;
            }
            if(user!="admin" && pass!="admin"){
                JOptionPane.showMessageDialog(null, "Try again! Invalid username or password!","Error Logging-In", JOptionPane.ERROR_MESSAGE);
            tryAgain = false;
        }
    }while(tryAgain = true);
            }
        }


What I want to happen is that once the user entered wrong username or password the program will then loop. But if the user entered the correct username or password, it wont loop asking the user for the correct one.
AnswerRe: problem with looping Pin
Richard MacCutchan20-Feb-13 22:56
mveRichard MacCutchan20-Feb-13 22:56 
AnswerRe: problem with looping Pin
ameymh21-Feb-13 18:59
ameymh21-Feb-13 18:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.