String foo = (bar!=null)? value1 :
value2;
System.out.println("hello world");
值1和value2可以很长,因此分为两行。
java编辑器:格式上述代码(ctrl
+
I),并获得以下结果:
String foo = (bar!=null)? value1 :
value2;
System.out.println("hello world");
source代码可能很大,并且选择全部,然后按(
+I
)方便,以格式化整个代码。有没有办法避免上面的格式错误? 谢谢
您可以使用单行注释//
String foo = (bar != null) ? //
value1 : //
value2;
System.out.println("hello world");
}Importjava.util.scanner;
{
静态扫描仪SC =新扫描仪(System.in);
公共静态void main(string [] args)抛出异常
{
System.out.print(“输入您的百分比:”);
双百分比= sc.nextdouble();
System.out.println(“ processing ....”);
thread.sleep(3000);IF(百分比> 100 ||百分比
System.out.println(“无效百分比”);
else if(百分比> = 70)
SYSTEM.OUT.PRINTLN(“ DICKINCTION”);
ELSEif(百分比> = 60)system.out.println(“ first Class”);<0)
else if(百分比> = 50)
System.out.println(“ class”);
else if(百分比> = 30)
System.out.println(“ Pass”);
else
System.out.println(“失败”);
}
}