Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Java code format specification?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is Java code format specification". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

/** * Java coding format personal recommendation, reference JDK source code and Hyperic HQ source code (formerly known as Spring's open source software, vmware is now). * @author lihzh(bitter forced coder) * Address: mushiqianmeng.blog.51cto.com/3970029/737120 */ public class CodeRule { //Declare variables with spaces on both sides of the equal sign. private static int i = 1; //Method declaration with spaces between right and left braces. public static void main(String[] args) { //if statement, comparison connector (>) left and right spaces, parentheses and braces between spaces. //if and left parenthesis have spaces between them if (i > 0) { System.out.println(i); } //A concatenation (&&) of two conditions, with spaces left and right. if (i > 0 && i

< 2) { System.out.println(i); } //if..else 语句两种格式 //1.参考JDK,个人使用方式,else跟大括号,前后都有空格 if (i >

0 && i

< 2) { System.out.println(i); } else if (i >

2) { System.out.println(i + 1); } else { System.out.println(i); } //2. Refer to Hyperic HQ source code, else start another line, there are still spaces after if (i == 1) { System.out.println(i); } else { System.out.println(i); } //while statement, and if statement type, while and brackets have spaces in between, brackets format is the same as if while (i > 0 && i < 2) { System.out.println(i); i++; } //for statement, two formats //1. Refer to Hyperic HQ, Personal Usage. Semicolons followed by spaces, each substatement, connectors left and right with spaces. //for and brackets with spaces in between, brackets with spaces in between. for (int j = 0; j < 10; j++) { System.out.println(i); } //2. Refer to JDK, the difference is that in the substatement, there is no space around the connector. for (int j=0; j 2 ? 1 : -1; //Method declarations and calls, comma-separated arguments, spaces after commas. sum(a, b); sum(c + d, j); } //method declaration, multiple parameters, spaces after commas private static int sum(int i, int j) { return i + j; } }"Java code format specification is what" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report