Hewlett Packard Interview Question
Software Engineer / DevelopersTeam: Networking
Country: United States
Interview Type: In-Person
public class Test {
private String WORD = "I am in love with New York";
private int count = 0;
private char[] chars = new char[5];
public void read() {
concat(getChar(2));
concat(getChar(3));
concat(' ');
concat(getChar(5));
concat(getChar(6));
System.out.print(String.copyValueOf(chars));
}
private void concat(char letter) {
chars[count] = letter;
count++;
}
private char getChar(int position) {
return WORD.charAt(position);
}
Simple java solution
}
- dkpractice October 19, 2015