Java_week3

循环:

//Ctrl+c  强制结束命令行

 

for 循环的无限循环形式:  for( ; ; )()

 

while循环的无限限循环形式:while(true)

w:for(int y=0;y<4=3;y++)       //w 为for循环的名字
  {
    q:for(int x=0;x<4;x++)  //q 为for循环的名字

      {.....

        break w;    //跳出 w 循环

      }

函数结构:

public static int Fun(int num)   //public 可省

{

return num*3+5;

}

函数重载:

数组定义方式:

//元素类型[] 数组名 = new 元素类型[元素个数或数组长度]

int[] x = new int [3];

int x[] = new int [3];

获取数组的长度: 数组名.length

Java 中

栈内存 数据使用完毕,会自动释放。//局部变量都在栈

堆内存//存放new开辟的实体空间,堆内存中的变量都有默认初始值

错误提示:

 //ArrayIndexOutofBoundsExceotion:3  操作数组时,访问到了数组中不存在的角标

二维数组:int[] [] arr = new int [2][3]

 

有疑惑的点 是  StringBuffer  s = new StringBuffer(); 的应用

 

下周学习面向对象的一部分。

原文地址:https://www.cnblogs.com/janeszj/p/9384326.html