As far as I know, the logic in conditional and loop statements are the same whether it is C# or Java.
class WhileLoops {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
String answer = "";
/*do{
System.out.println("Will you be my girlfriend?(Yes/No)");
answer = input.nextLine();
}while(answer != "Yes" && answer != "Yes");*/
while(answer != "Yes" && answer != "yes") {
System.out.println("Will you be my girlfriend?(Yes/No)");
answer = input.nextLine();
}
System.out.println("I promise to make you feel special.");
}
}
as you can see in the code above I used do-while and while just setting either one as a comment when I will compile and run.
This is what happens when I run the program: