活跃农民
- 积分
- 616
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2014-10-13
- 最后登录
- 1970-1-1
|
1 int size = 27; //declare an integer size,ssign it size with 27
2 String name = "Fido"; //declare a string name,assign it with Fido
3 Dog myDog = new Dog(name, size); //decalare a Dog object named myDog with instant variable name and size
4 int x = size - 5; //declare an integer x, assign x with size-5
5 if (x < 15) {
6 myDog.bark(8);
7 }//if x is less than 15,then invoke myDog's method bark() with argument 8
8
9 while (x > 3) {
10 myDog.play();
11 }//while x is greater than 3, then invoke myDog's method play()
12
13 int[] numList = {2, 4, 6, 8};//declare an integer array numList with 2,4,6,8
14 System.out.print("Hello ");//print 'Hello'
15 System.out.println("Dog: " + name); //print 'Dog:'+ name(Fido)
16
17 System.out.println(numList[1]); //print the integer in numList with index 1
18 if (numList[3] == 8) {
19 System.out.println("potato");
20 }//if numlist[3] equals 8, then print potato
2
returns 2
return the smallest value's index after kth value
sorting the array in ascending order
3.
public static int fib(int N)
if (N < 2){ return N;}
return fib(N-1)+fib(N-2)
|
|