Write code to get first char from string
//package com.book2s; public class Main { public static void main(String[] argv) { String input = "book2s.com"; System.out.println(getFirstCharFromInput(input)); }/* w w w .j a v a 2 s .c o m*/ public static char getFirstCharFromInput(String input) { if (input.length() == 1) { return input.charAt(0); } else if (input.equals("\\n")) { return '\n'; } else if (input.equals("\\t")) { return '\t'; } else { return 0; } } }