انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية تكنولوجيا المعلومات
القسم قسم البرامجيات
المرحلة 2
أستاذ المادة احمد مهدي محمد سعيد الصالح
31/01/2016 18:43:12
The Java compiler translates Java source code into a special representation called bytecode • Java bytecode is not the machine language for any traditional CPU • Another software tool, called an interpreter, translates bytecode into machine language and executes it • Therefore the Java compiler is not tied to any particular machine • Java is considered to be architecture-neutral Input in Java: JOptionPane is a easy way to do dialog boxes, messages or inputs. You have to import it at the beginning of the program: //A sample program. Sample.java import javax.swing.JOptionPane; // imports JOptionPane class public class Sample { public static void main ( String args[] ) { JOptionPane.showMessageDialog ( null, "This is a sample program" ); Java source code Machine code Java bytecode Bytecode interpreter Bytecode compiler Java compiler OOP with Java Programming 2rd class – Department of Programming Dr. Ahmed Al-Salih College of IT- University of Babylon 14 System.exit ( 0 ); //stops the program } } There are different kinds of icons for a dialog box, just replace the last argument: JOptionPane.PLAIN_MESSAGE // this is a plain message JOptionPane.INFORMATION_MESSAGE // this is a info message JOptionPane.ERROR_MESSAGE // this is a error message JOptionPane.WARNING_MESSAGE // this is a warning message You can also use JOptionPane for dialog boxes for input, and assign them to variables, just put: name= JOptionPane.showInputDialog("put your message here" ); Example import javax.swing.JOptionPane; //import class JOptionPane public class Addition { public static void main ( String args[] ) { String firstNumber, secondNumber; int number1, number2, sum; //read in the first number from user as a string firstNumber = JOptionPane.showInputDialog ( "Enter first integer" ); //read in the second number from user as a string secondNumber =JOptionPane.showInputDialog ( "Enter second interger"); //convert numbers from type String to type int number1 = Integer.parseInt ( firstNumber); number2 = Integer.parseInt ( secondNumber); //add the numbers sum = number1 + number2; //display the results JOptionPane.showMessageDialog ( null, "The sum is " + sum,"Results",JOptionPane.PLAIN_MESSAGE); System.exit ( 0 ); //ends the program } } OOP with Java Programming 2rd class – Department of Programming Dr. Ahmed Al-Salih College of IT- University of Babylon 15 ? Java basic operator: We can divide all the Java operators into the following groups: ? Arithmetic Operators ? Relational Operators ? Bitwise Operators ? Logical Operators ? Assignment Operators 1- The Arithmetic Operators: Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The following table lists the arithmetic operators: Assume integer variable A holds 10 and variable B holds 20
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|