What is Wrong With My Exception Class Code?
This is what I have so far:
Code Java:
class Customer{
private String name;
private int age;
public Customer(String n, int a)throws CreateException{
if(0<a<125){
Name=n;
Age=a;
throw new CreateException(“ Age limit is 0 to 125 ”);
}
}
public void print(){
System.out.println(" The Name:" +Name);
System.out.println(" The Age:" +Age);
}
}
public class CustomerDemo{
public static void main(String args[]){
Customer cust[]=new Customer[2];
for(int i=0;i<2;i++){
try{
c[0]=new Customer(“Ram”,60);
c[0].print();
}catch(CreateException e){
System.out.println(“ Complete ”);
System.out.println(e.getMessage());
}
}
}
}
Re: What is Wrong With My Exception Class Code?
Where is CreateException class?
Re: What is Wrong With My Exception Class Code?
Quote:
Originally Posted by
hardikjadhav
Where is CreateException class?
Exactly. Can we please see all of your code.
What problems are you currently having?
Re: What is Wrong With My Exception Class Code?
What's the "CreateException class" ?? Mainly it does not read the quotes and says I should have semicolons in places that seem strange to have them in.