Put the whole code block in a while loop
with
while((type!=1 && type!=2))
{
...
}
this will do the trick
More Related Contents:
- ArrayList, Loop and requisite if can not work that i want – Java 11
- How to get out of while loop in java with Scanner method “hasNext” as condition?
- Scanner input validation in while loop
- Does Java recognize infinite loops?
- If-else One line statement (with string and integer) [closed]
- Why does the if statement “if(1)” give error in Java but it holds true in C++?
- Result from printing statement and if statement differ
- Conditional Statement on Java7
- Multiple statement is passed in IF condition using OR, how to find which statement is true?
- Optimizing a while loop in Java
- Sorting ArrayList based on number of duplicates? [closed]
- How does a for loop work, specifically for(;;)?
- In Java, what are the advantages of streams over loops? [closed]
- Enhanced ‘for’ loop causes an ArrayIndexOutOfBoundsException
- How to do if-else in Thymeleaf?
- Why doesn’t my compare work between char and int in Java?
- Display numbers from 1 to 100 without loops or conditions [closed]
- Is there any way to do n-level nested loops in Java?
- Java for loop vs. while loop. Performance difference?
- Increment variable names? [duplicate]
- Should try…catch go inside or outside a loop?
- Refactoring if/else logic
- Java: how much time does an empty loop use?
- Java How can I break a while loop under a switch statement?
- using labels in java without “loops”
- How is String in switch statement more efficient than corresponding if-else statement?
- How to use goto statement correctly
- Java Delay/Wait
- Java: For-Each loop and references [duplicate]
- If-else working, switch not [duplicate]