Stack Overflow Asked on December 18, 2020
When I write a Switch statement in Java (I use IntelliJ IDEA), the blinking cursor, or caret, doesn’t go to the next line correctly. It’s not really a huge problem, but just an annoyance I’m not sure how to fix.
When I write a case for a switch code block:
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;
}
After the ‘break;’, when I enter the cursor stays inside the case 1 code block
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;
<-- The cursor goes here
}
And when I backspace to move it back so I can make a new case, the line just goes back to the end of the break;
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;<-- cursor goes here
}
The only way I can move it to create a new case 2 is to manually use my directional keys 4 spaces after I press enter. Is there a keyboard shortcut where I can create a new case without the extra steps?
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;
<-- cursor goes here and after I use the directional keys
case 2:
System.out.println("Value was 2");
break;
}
This was a really obscure minor issue I can’t seem to find the answer for.
I think I fixed my own issue after posting the question.
If I just type "case 2:" after going to the next line after the "break;", IntelliJ IDEA will automatically format the case and move it to the correct position without any hassle.
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;
case 2:
}
The moment you finish the case statement with the colon, the editor will automatically format the line and move the statement to the correct position.
switch(switchValue){
case 1:
System.out.println("Value was 1");
break;
case 2:
}
Correct answer by Danny on December 18, 2020
0 Asked on December 7, 2021
1 Asked on December 7, 2021 by rampatowl
3 Asked on December 7, 2021 by grizzly-bear
7 Asked on December 7, 2021 by jordan-baucke
1 Asked on December 7, 2021 by maeror
1 Asked on December 7, 2021 by basic-coder
2 Asked on December 7, 2021 by paul-van-oudheusden
azure active directory invitation microsoft graph api redirect
1 Asked on December 7, 2021 by plumo
1 Asked on December 7, 2021
5 Asked on December 7, 2021 by raj-kumar-boddu
1 Asked on December 7, 2021 by chatanooga
0 Asked on December 7, 2021 by jay-chu
1 Asked on December 7, 2021 by bharav
0 Asked on December 7, 2021 by jpo38
2 Asked on December 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP