美文网首页
2020-01-05 Java学习历程(on Java 核心技术

2020-01-05 Java学习历程(on Java 核心技术

作者: frank_zhang1 | 来源:发表于2020-01-05 15:24 被阅读0次

Java 的基本程序设计结构


1. Java代码的风格

    a. Main + line , example

        Public class ClassName

        {

            public static void main(String[]args)

            {

                //program statement, each line is end with ;

                System.out.println(“it is a program statement!!!”);

            }

        }

    b. annotation

        1. //   using for annotating one line

        2./*.........*/  using for annotating a few lines

        3./**.........*/ not only annotatating a few lines ,but also it can be using for create document atomatically

    2. Type of Data

        int: 4bytes; short: 2 bytes;long: 8bytes; byte: 1byte;

        float: 4bytes; double: 8 bytes

        constant : final basType = value;

        attention: 

        1. please pay attention to the range of data in each type. try not to do data conversion from long lenth to short one

        2. do not do comparesion between float and double , some times, float 2.1f > double 2.1 or float 1/18f =double 1/18f and float 2.1f < double 2.1f, this is related to computer data mechanism

            such as snapshot A.the next scrpts, a is always greater than b

                            snapshot B. a==b ,but the value is not equal. 

           so , please pay more attention to use this type of data

                

    3. Operator

            +,- ,*,/

        a. coercion

            base type:int a = 1; float fa = (float) a ;

            basetostring: 1. String.valueOf(val) 

                                  2. baseType.toString(val) (baseType is the data type of val)

            stringtobaseType:  int:  Integer.parseInt(str); float: Float.parseFloat(str); ...

        b.logical Operators

            !=; >; <; >=;<=;&& ; ||;

            && is in short-circuit operation, like expresion1 &&expression2   , when using it , if expression1 is true, do expression2, if expression1 is False, expression2 is not excuted , 

            || is also the same style, expression1 || expression2, if expression1 is true, expression2 is not excuted,result is true, if expression1 is false, do expression2

        c. bit operations

            &(and), |(or),^(xor),~(not),<<(left shift);>>(right shift ,hight part is filled with symbol bit);>>>(right shift,hight part is filled with zero)

    4. String

        String a = "HelloWorld!!!" ; String str = "H"; String b = "Demo"

        frequently method: 

            a.Substring(int beginIndex, Int endIndex): return to a substring from beginIndex to endIndex-1

            b. a.length():return to the length of string a

            c. a.indexof(str,int beginIndex) : return to the index of first string str searching from beginIndex 

            d. a.trim(): return to a new string without trim space at head and top postion

            e. String.join(delimiter:";",a,b): return to a new string which is joined by a and b with ;

            f:a.equals(b): return to the result of weather a is equal to b

            attention: if the string is offen changed , please use a dynamic class StringBuilder,which is more efficient than String, because String is a static length class , whereas StringBuilder is a dynamic one , considering static string , there need more time to create a new string when changing the string.  we can ref to this site: https://blog.csdn.net/qq_24025219/article/details/99692955 

       5. control 

            a. if

                if (condition){

                        statement;

                } else if (condition){

                    statement;

                }

                else{

                    statement;

                }

            b. while

                while (condition) {

                    statement;

                }

            c. do while 

                do{

                    statement;

                } while (condition);

            d. for

                 for(condition){

                    statement;

                }

            e. switch

                switch(choice){

                    case choicevalue:

                    ...

                    break;

                    case choicevalue2:

                    ...

                    break;

                    default:

                    ...

                    break;

                }

                example:

相关文章

  • Java 语言原理

    Java核心技术讲解学习一 Java核心技术讲解学习二 Java核心技术讲解学习三 Java核心技术讲解学习四 J...

  • # [Java学习]1.Java基础【学习笔记】

    [Java学习]1.Java基础【学习笔记】 书籍 《Java核心技术》、《Java核心技术精讲》 2018-09...

  • 2020-01-05 Java学习历程(on Java 核心技术

    第一/二两章的核心 1.Jdk, jre, jvm的不同 jdk中现在都自带jre,而jre中包含jvm。 a...

  • 2020-01-05 Java学习历程(on Java 核心技术

    Java 的基本程序设计结构 1. Java代码的风格 a. Main + line , example Publ...

  • java修炼书籍

    1,《java核心技术(卷1)》 2,《java核心技术(卷1)》 3, 《java学习指南(第四版)》 4,《e...

  • 双11Java程序员书单推荐

    Java 《Java核心技术卷I》 《Java核心技术卷II》 《Java编程思想》 《Java并发编程实战》 《...

  • Java SE基础部分

    Java核心语法 书籍:《Java核心技术卷一》《Java核心技术卷二》 java包结构:核心包,Java1一同出...

  • 记录一些书籍

    JAVA 基础 《Java核心技术·卷1:基础知识》《Java核心技术 卷2:高级特性》《Java8 实战》 并发...

  • Java核心知识

    Java核心语法 作者:springremember 书籍:《Java核心技术卷一》《Java核心技术卷二》 ja...

  • 学习java的书籍

    Java基础部分 [JAVA核心技术 Head First Java 重构 Effective java 中文版(...

网友评论

      本文标题:2020-01-05 Java学习历程(on Java 核心技术

      本文链接:https://www.haomeiwen.com/subject/hluqactx.html