Hi... I think you have to work hard on your basics..
1) if(0<a<125) condition is wrong. It could be if((0<a)&&(a<125))
2) Your declared variables are
private String name;
private int age;
And you are using
Name=n;
Age=a;
This is again basic, declared name of variable are different then assigned one.
3) In customer demo class
c[0]=new Customer(“Ram”,60);
c[0].print();
Where is the array of c, i think it should be cust.
---------------------------------------------------
package com.java.main;
class Customer {
private String name;
private int age;
public Customer(String n, int a) throws Exception {
if ((0 < a) && (a < 125)) {
name = n;
age = a;
throw new Exception("Age limit is 0 to 125");
}
}
public void print() {
System.out.println(" The Name:" + name);
System.out.println(" The Age:" + age);
}
}
----------------------------------------------------
package com.java.main;
public class CustomerDemo {
public static void main(String args[]) {
Customer cust[] = new Customer[2];
for (int i = 0; i < 2; i++) {
try {
cust[0] = new Customer("Ram", 60);
cust[0].print();
} catch (Exception e) {
System.out.println("Complete");
System.out.println(e.getMessage());
}
}
}
}