Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: What is Wrong With My Exception Class Code?

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What is Wrong With My Exception Class Code?

    This is what I have so far:
    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(&#8220; Age limit is 0 to 125 &#8221;);
    }
     
    }
     
    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(&#8220;Ram&#8221;,60);
    c[0].print();
    }catch(CreateException e){
    System.out.println(&#8220; Complete &#8221;);
    System.out.println(e.getMessage());
    }
    }
    }
    }


  2. #2
    Junior Member
    Join Date
    Apr 2011
    Location
    Pune, India
    Posts
    11
    My Mood
    Cool
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: What is Wrong With My Exception Class Code?

    Where is CreateException class?
    Hardik Jadhav

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: What is Wrong With My Exception Class Code?

    Quote Originally Posted by hardikjadhav View Post
    Where is CreateException class?
    Exactly. Can we please see all of your code.

    What problems are you currently having?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  4. #4
    Junior Member
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

Similar Threads

  1. What is Wrong with my code
    By xew123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 8th, 2011, 04:59 AM
  2. what is wrong in this code
    By rk.kavuri in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 6th, 2011, 03:13 PM
  3. What is wrong with this code class not found
    By newbieJava in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 19th, 2011, 06:39 PM
  4. What is wrong with my code???
    By nine05 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 8th, 2011, 09:59 AM
  5. What is wrong with my code?
    By phantom06 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 3rd, 2011, 05:21 AM