赞
踩
public class Test { public static void main(String[] args) { int a=10; int b=10; method(a,b);//需要在method方法被调用之后,仅打印出a=100,b=20,请写出method方法的代码 System.out.println("a="+a); System.out.println("b="+b); } //代码编写处 //方法一 public static void method(int a,int b) { a=a*10; b=b*20; System.out.println("a="+a); System.out.println("b="+b); System.exit(0); } }
import java.io.PrintStream; public class Test { public static void main(String[] args) { int a = 10; int b = 10; method(a, b);//需要在method方法被调用之后,仅打印出a=100,b=20,请写出method方法的代码 System.out.println("a=" + a); System.out.println("b=" + b); } //代码编写处 //方法二 public static void method(int a, int b) { PrintStream ps = new PrintStream(System.out) { @Override public void println(String x){ if ("a=10".equals(x)) { x = "a=100"; } else if ("b=10".equals(x)) { x = "b=200"; } super.println(x); } }; System.setOut(ps); } }
public class Test {
public static void main(String[] args) {
int[] arr = new int[]{12,3,3,12,24,36,213,523};
//方法一
for(int i =arr.length-1;i>=0;i--){
arr[i]=arr[i]/arr[0];
}
for (int i =0;i<=arr.length;i++){
System.out.println(arr[i]);
}
}
}
public class Test {
public static void main(String[] args) {
int[] arr = new int[]{12,3,3,12,24,36,213,523};
//方法二
int temp=arr[0];
for(int i =0;i<arr.length;i++){
arr[i]=arr[i]/temp;
}
for (int i =0;i<=arr.length;i++){
System.out.println(arr[i]);
}
}
}
public class ArrayPrintTest {
public static void main(String[] args) {
int[] arr=new int[]{1,2,3};
System.out.println(arr);//地址值
char[] arr1 = new char[]{'a','b','c'};
System.out.println(arr1);//abc
}
}
结果
public class ArrayPrintTest {
public static void main(String[] args) {
int[] arr=new int[10];
System.out.println(arr);//地址值
char[] arr1 = new char[10];
System.out.println(arr1);//空的字符类
}
}
结果
char和string 是值 int啥的是地址值
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。