Skip to main content

Posts

Showing posts from March 18, 2017

Nested Classes sample program

Nested Classes In Java, just like methods, variables of a class too can have another class as its member. Writing a class within another is allowed in Java. The class written within is called the nested class , and the class that holds the inner class is called the outer class . class Outer {  private class Inner  {    void dispaly()    {        System.out.println("this is inner class");       }   }  void call()  {    Inner obj=new Inner();    obj.dispaly();  } } class InnerDemo { public static void main(String s[]) {  Outer ob=new Outer();  ob.call(); } } Example solve watch video for understanding  // inner class By Prakash Sonar class outer {  private class Inner  {    void display()   {      System.out.println...

Steps to create user define exception in java

How to create user define exception in java ? Lets Create user defied exception in java . In this java tutorial i am using simple java code example where we accept number from user if number is one our program will throw user defied exception . You will find video tutorial also for this assignment on you tube . there are different types of exception in java mainly 1.User Defined   (user need to handle this exception) 2. System Defined ( it is defined by system itself/ Default  ) we are going to use following block in our program         try         {    //Program logic goes here  } catch           {    } finally           {     } Steps to create user define exception in java  create user define exception class which extends Exception define constructor for user defined exception class ...

Labels

Show more