知乎专栏 |
目录
获取 Class 名称
Log.d(TAG, this.getClass().getName());
修饰符 返回值类型 方法名(参数类型…变量名){}
package cn.netkiller.test; public class Test { public static void main(String[] args) { Test test = new Test(); int total = test.sum(2, 4, 6, 8); System.out.println(total); test.print(1, 3, 5, 7); } public int sum(int... number) { int total = 0; for (int i = 0; i < number.length; i++) { total += number[i]; } return total; } public void print(Object... obj) { for (int i = 0; i < obj.length; i++) { System.out.printf("%s,", obj[i]); } } }