Hackerss.com

hackerss
hackerss

Posted on

Create a class for a point in Java

Create a class for a point - Java:


/**
 * This class is used to create a point with javadoc
 * @author 
 * @version 1.0
 */
public class Point {
   /**
   * This method is used to create a point with javadoc
   * @param x is the x coordinate of the point
   * @param y is the y coordinate of the point
   */   
   public void createPoint(int x, int y) {
       //Variable to store the total sum
       int total = 0;
       //Sum the two numbers
       total = x+ y;
       //Return the total
       return total;
   }

   /**
   * One Example
   */
   public static void main(String args[]) throws IOException {

      Point  point= new Point ();
      //Example
      int sum = point.createPoint(10, 20);
      //Output
      System.out.println("Sum of 10 and 20 is :" + sum); //30
   }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)