Code fragment-easy for readers to read code in a neat format

Source: Internet
Author: User

This article is based on the art of writing readable code. It is very well written!

Sometimes, we can use column alignment to make the code easier to read. The instance code is as follows:

Package COM. jue. test; public class student {// a meaningful sorting order in which public final static int index_id = 0; public final static int index_name = 1; public final static int index_phonenumber = 2; public final static int index_address = 3; // a meaningful sorting order of int ID; string name; string phonenumber; string address; Public student () {} public student (int id, string name, string phonenumber, string address) {// a meaningful sorting order this. id = ID; this. name = Name; this. phonenumber = phonenumber; this. address = address;} public student (Student) {// a meaningful arrangement order this. id = student. ID; this. name = student. name; this. phonenumber = student. phonenumber; this. address = student. address;} private int copyfromcursor (cursor c) {// a meaningful sorting order this. id = C. getcolumnindexorthrow (index_id); this. name = C. getcolumnindexorthrow (index_name); this. phonenumber = C. getcolumnindexorthrow (index_phonenumber); this. address = C. getcolumnindexorthrow (index_address);} public static void main (string ARGs []) {student Xiaoming = new student (0, "Zhang Xiaoming", "15010112299", "Xinjiang Uygur Autonomous Region "); student Wanggang = new student (1, "Wang Gang", "13900000099", "Beijing"); Student liyue = new student (2, "Li Yue", "18510112299 ", "Tibet Tibetan Autonomous Region"); Student WangLi = new student (3, "Wang Li", "13588112299", "Yunnan Province ");}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.