- 博客(8)
- 收藏
- 关注
原创 静态导入包
package learning; //静态导入包 import static java.lang.Math.random; import static java.lang.Math.PI; public class Demo06 { public static void main(String[] args) { //对比两者区别 System.out.println(Math.random()); System.out.println(Math.PI); System.out.pri
2020-10-10 22:41:12 143
原创 静态和非静态的区别
package learning; public class Demo05 { // 静态和非静态的主要区别是:静态可以通过类名直接调用而非静态则需要通过实例类对象进行调用 // private static int age; // private int num; // public static void run() { // System.out.println("我是静态方法"); // } // public void go() { // System.out.println("我是非静态
2020-10-10 22:39:59 577
原创 稀疏数组的读取和存入
public static void main(String[] args) { // TODO 自动生成的方法存根 int [][]array1=new int[11][11]; array1[1][2]=1; array1[2][3]=2; //输出原数组 System.out.println("输出原始的数组"); for (int[] ints : array1) { for (int anInt : ints) { System.out.print(anI
2020-10-03 23:18:16 104
原创 数组的使用及其反向数组
public static void main(String[] args) { // TODO 自动生成的方法存根 int [] arrys= {1,2,3,4,5}; //遍历打印 for (int i = 0; i < arrys.length; i++) { System.out.println(arrys[i]); } //求和 int sum=0; for (int i = 0; i < arrys.length; i++) { sum+.
2020-10-03 14:02:23 212
原创 数组的申明与创建
public static void main(String[] args) { // TODO 自动生成的方法存根 //数组的申明 int [] num; //数组的创建 num=new int[10]; num [0]=1; num [1]=2; num [2]=3; num [3]=4; num [4]=5; num [5]=6; num [6]=7; num [7]=8; num [8]=9; num [9]=10; int sum=0; for(int i=0;i
2020-10-02 23:12:49 59
原创 递归的入门
public static void main(String[] args) { // TODO 自动生成的方法存根 //运行进行检验 System.out.println(f(3)); } //实现递归的方法 public static int f(int n) { if(n==1) { return 1; }else { return n*f(n-1); } } ...
2020-10-02 22:04:11 59
原创 基本方法的调用与重载
public static void main(String[] args) { // TODO 自动生成的方法存根 double sum=add(10.0, 20.0,20); System.out.println(sum); } public static int add(int num1,int num2) { return num1+num2; } public static double add(double num1,double num2) { return num1+n
2020-10-01 21:47:57 921
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人