java数组与异常处理复习题(6)

2021-02-21 20:02

数组,异常处理,常用类。

public void change(String str, char ch[]) {

str = "How are you";

ch[1] = 'u';

}

}

运行结果是:( Hi ! Luke )

2. 分析下面的程序,写出运行结果:

public class Exercises5_3 {

public static void main(String args[]) {

String str1 = new String();

String str2 = new String("String 2");

char chars[] = { 'a', ' ', 's', 't', 'r', 'i', 'n', 'g' }; String str3 = new String(chars);

String str4 = new String(chars, 2, 6);

byte bytes[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };

String str5 = new String(bytes);

StringBuffer strb = new StringBuffer(str3);

System.out.println("The String str1 is " + str1); System.out.println("The String str2 is " + str2); System.out.println("The String str3 is " + str3); System.out.println("The String str4 is " + str4); System.out.println("The String str5 is " + str5); System.out.println("The String strb is " + strb); }

}

运行结果是:( )

The String str1 is

The String str2 is String 2

The String str3 is a string

The String str4 is string

The String str5 is 0123456789

The String strb is a string

五、改错题

1.找出下面代码的错误部分,说明错误类型及原因,并更正。 public int m1 (int number[20]){

number = new int[20];

for(int i=0;i<number.length;i++)

number[i] = number[i-1] + number[i+1];

return number;

}

改正后程序:

public int[] m1(int number[]) {

// number = new int[20];


java数组与异常处理复习题(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017-2022氖气行业市场需求分析及投资预测报告

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: