Page 198 - CITS - CSA - TP (Volume 2) - Hindi
P. 198

कं  ूटर सॉ वेयर ए ीके शन - CITS




           अ ास 115: JAVA म  पैके ज बनाएं  और उसका उपयोग कर  (Create and use a package in JAVA)


            उ े

           इस अ ास के  अंत म  आप यह कर सक  गे
           •   जावा म  पैके ज बनाने और उपयोग करने के  िलए जावा  ो ाम डेवलप करना।

           आव कताएं  (Requirements)

           उपकरण/साम ी (Tools/Materials)

           •   िवंडोज OS वाला PC/लैपटॉप
           •   SDK सॉ वेयर
           •   टे  एिडटर (िवजुअल  ू िडयो/सबलाइम/नोटपैड)

            ि या (Procedure)

           टा  1: पैके ज बनाएं  और उसका उपयोग कर
           package p2;

           import java.util.Scanner;
           public class Sub {
               int d;

               public void diff() {
                   Scanner scan = new Scanner(System.in);
                   System.out.print(“Enter the first number: “);

                   int x = scan.nextInt();


                   System.out.print(“Enter the second number: “);

                   int y = scan.nextInt();


                   d = x - y;

                   System.out.println(“Difference = “ + d);



                   // Close the Scanner to release resources
                   scan.close();
               }

               // Main method for testing
               public static void main(String[] args) {
                   Sub sub = new Sub();

                   sub.diff();
               }
           }



                                                           184
   193   194   195   196   197   198   199   200   201   202   203