import java.io.*;
public class Mainclassexec
{
public static void main(String[] args)
{
String input = null;
try
{
String capitalized = capitalize(input);
System.out.println(capitalized);
} catch (NullPointerException e)
{
System.out.println(e.toString());
}
}
public static String capitalize(String s) throws NullPointerException
{
System.out.println("Enter a string");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
s=br.readLine(); //--->error here IOException must be caught
// or declared to be thrown
if (s == null)
{
throw new NullPointerException("You have passed a null argument");
}
Character firstChar = s.charAt(0);
String theRest = s.substring(1);
return firstChar.toString().toUpperCase() + theRest;
}
}
How should i clear this error? Also please suggest me some site to learn exception handling I am very confuse with this topic.