Leave a Reply 3

Your email address will not be published. Required fields are marked *


Roger Wilco

Roger Wilco

A

public class Test1 {

public static void main(String[] args) {
String[] names = new String[3];
names[0] = “Mary Brown”;
names[1] = “Nancy Red”;
names[2] = “Jessy Orange”;

try {
for(String n : names){
try {
String pwd = n.substring(0, 3) + n.substring(6, 10);
System.out.println(pwd);
} catch (StringIndexOutOfBoundsException e) {
System.out.println(“string index out: ” + e);
}
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(“array out”);
}

}

}