Java Programming by Derek Banas
Introduction
James Gosling initiated Java Language project 1991 for the use of one of the many set of top box projects. The language is initially called oak and later renamed Java, Sun released its first implementation as Java 1.0 in 1995, it promised Write Once Run Anywhere (WORA), on 2006 Sun released Java as a free and open source software.
Java is a general-purpose computer programming language, According to TIOBE Index it is one of the most popular programming languages in use, that is object-oriented and specifically designed to have as few implementation dependencies as possible. Java code can run on all platforms that support Java without the need for recompilation, Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.
Simple Program in Java
//Simple hello–‐world program public class ClassName { //The main method is the first thing executed public static void main(String args[]){ System.out.printf(“Hello”); } } |
Comments
comments are used to document your code, any text in Java, they explain your programs and improve program readability, they ignored by compiler, two types
Single-line comment such as // This is a text-printing program. Multi-line comment Start with /*End with */ |
Getting Some Input
//This is how we import outside code import java.util.Scanner; public class ClassName { public static void main(String args[]){ Scanner input= new Scanner(System.in); int num1, num2, num3; System.out.printf(“Enter an integer:”); num1=input.nextInt(); System.out.printf(“Enter another integer:”); num2=input.nextInt(); num3=num1+num2; System.out.printf(“The sum is:%d\n”,num3); } } |
References:
Banas. D.(2014, June 3). Java Programming [Video File]. Retrieved from. https://www.youtube.com/watch?v=WPvGqX-TXP0