Java Foundation study notes (a)

Output classic Hello world!

public class Main{
    public static void main(String[] args){
        System.out.println("Hello world");
    }
}

const is a reserved keyword java is not currently used, you must use the final definition of the constants
has many methods in the Math class, you can call the sqrt method to find square root of a digital transport
calculation results, requires the use of import to call the Math class, because there is no like C ++, C library provides
functions for handling input, java input method requires the use of read data read. Made
to create objects in java is fully object-oriented language will need new.

import java.util.Scanner;
import java.math.*;
public class Main {
    public static void main(String[] args){
        Scanner how=new Scanner(System.in);
        int number=how.nextInt();
        System.out.println(Math.sqrt(number));
    }
}

Above to import calls the standard library by using the class to get input and Math class
sqrt method to square root of the number.
const is a reserved keyword java is not currently used, you must use the final definition of constants
java method were detected with the array length of C ++, C, due to the fully object-oriented such that the early
scholars look ignorant , java in the class is really powerful processing just in front of large numbers tune
with the Math class:

import java.util.Scanner;
import java.math.*;
public class Main {
    public static void main(String[] args){
        Scanner how=new Scanner(System.in);
        BigInteger number=how.nextBigInteger();
        BigInteger number_=how.nextBigInteger();
        number=number.add(number_);
        System.out.println(number);
    }
}

只是有个问题不能直接使用系统的默认运算符得通过调用add方法
进行大数相加的问题,倒是长度比某语言写出的短了不少运行效率
大家都知道挺快的
java在定义数组是和C++,C均区分了int []a仅是声明数组,要想
真正定义数组还得通过关键字new来开辟数组,int[] a=new int[10]
输出倒是可以变来变去听《Java核心技术卷》谈到输出中的printf
吸收了C语言输出的处理优点,println的效果同C++中cout <<endl;
效果一致输出后换行也可以用print输出后不换行,也可使用printf
输出自己想要的格式,由于面向对象使得java的每一个都包含在类中
还有个坑点:

public class Main {
    public static void main(String[] args){
       int i;
       for(int i=0;i<5;i++)
       {
           
       }
    }
}

我记得这玩意在C中天天做概念题作用域问题,Java核心技术卷提及无
法通过因为java认为这会导致程序运行错误,确实自己debug时特别
用Devc++使有些时候监视值都不会改变,方便的东西真的多,比如arr
ay.sort就可以直接对数组元素进行排序不用写个cmp再来排序极大
方便,而且是丢弃了指针这玩意因为谈及指针就想到了delete两次在
堆区具有相同内存因为使用编译器的浅拷贝造成的冲突使得出现故障
真是令人难以琢磨的bug。

Guess you like

Origin www.cnblogs.com/pekkasuper/p/12595841.html