import java.util.Scanner;
public class SB
{
public static void main(String []args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a string to shift characters");
String test = in.nextLine();
For further visit Javainhouse
Blog for Java,CoreJava,Collections Framework,Java Interview Questions ,Top Java Interview Questions ,Collections Interview Questions ,Java Programs,Android tutorial,Android Studio
![]() |
| JAXB Architecture |
| public
class InvalidAgeException extends Exception {} |
| public
class InvalidAgeException extends Exception { private int age; public InvalidAgeException () { super(); } public InvalidAgeException (String message, int age) { super(message); this.age = age; } } |
| public class CustomExceptionDemo { private static final Map<Integer, String> employee = new HashMap<>(); static { employee.put(100, "Mahesh"); employee.put(101, "Suresh"); employee.put(102, "Bran"); employee.put(103, "Troy"); } public static void main(String args[]) { CustomExceptionDemo t = new CustomExceptionDemo(); t.getAge(1000); } public String getAge(int age) { if (employee.get(age) == null) { throw new InvalidAgeException ("No such employee exists", age); } return employee.get(name); } } |