- Simple Programs In Java
- Sample Program In Java Using Inheritance
- Byte Code Sample Programs In Java
- Sample Programs In Java Exception Handling
Java Program to Print an Integer (Entered by the User) |
Java Program to Add Two Integers |
Java Program to Multiply two Floating Point Numbers |
Java Program to Find ASCII Value of a character |
Java Program to Compute Quotient and Remainder |
Java Program to Swap Two Numbers |
Java Program to Check Whether a Number is Even or Odd |
Java Program to Check Whether an Alphabet is Vowel or Consonant |
Java Program to Find the Largest Among Three Numbers |
Java Program to Find all Roots of a Quadratic Equation |
Java Program to Check Leap Year |
Java Program to Check Whether a Number is Positive or Negative |
Java Program to Check Whether a Character is Alphabet or Not |
Java Program to Calculate the Sum of Natural Numbers |
Java Program to Find Factorial of a Number |
Java Program to Generate Multiplication Table |
Java Program to Display Fibonacci Series |
Java Program to Find GCD of two Numbers |
Java Program to Find LCM of two Numbers |
Java Program to Display Characters from A to Z using loop |
Java Program to Count Number of Digits in an Integer |
Java Program to Reverse a Number |
Java Program to Calculate the Power of a Number |
Java Program to Check Whether a Number is Palindrome or Not |
Java Program to Check Whether a Number is Prime or Not |
Java Program to Display Prime Numbers Between Two Intervals |
Java Program to Check Armstrong Number |
Java Program to Display Armstrong Number Between Two Intervals |
Java Program to Display Prime Numbers Between Intervals Using Function |
Java Program to Display Armstrong Numbers Between Intervals Using Function |
Java Program to Display Factors of a Number |
Java Program to Make a Simple Calculator Using switch..case |
Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers |
Java Program to Find the Sum of Natural Numbers using Recursion |
Java Program to Find Factorial of a Number Using Recursion |
Java Program to Find G.C.D Using Recursion |
Java Program to Convert Binary Number to Decimal and vice-versa |
Java Program to Convert Octal Number to Decimal and vice-versa |
Java Program to Convert Binary Number to Octal and vice-versa |
Java Program to Reverse a Sentence Using Recursion |
Java Program to calculate the power using recursion |
Java Program to Calculate Average Using Arrays |
Java Program to Find Largest Element of an Array |
Java Program to Calculate Standard Deviation |
Java Program to Add Two Matrix Using Multi-dimensional Arrays |
Java Program to Multiply to Matrix Using Multi-dimensional Arrays |
Java Program to Multiply two Matrices by Passing Matrix to a Function |
Java Program to Find Transpose of a Matrix |
Java Program to Find the Frequency of Character in a String |
Java Program to Count the Number of Vowels and Consonants in a Sentence |
Java Program to Sort Elements in Lexicographical Order (Dictionary Order) |
Java Program to Add Two Complex Numbers by Passing Class to a Function |
Java Program to Calculate Difference Between Two Time Periods |
Java Code To Create Pyramid and Pattern |
Java Program to Remove All Whitespaces from a String |
Java Program to Print an Array |
Java Program to Convert String to Date |
Java Program to Round a Number to n Decimal Places |
Java Program to Concatenate Two Arrays |
Java Program to Convert Character to String and Vice-Versa |
Java Program to Check if An Array Contains a Given Value |
Java Program to Check if a String is Empty or Null |
Java Program to Get Current Date/TIme |
Java Program to Convert Milliseconds to Minutes and Seconds |
Java Program to Add Two Dates |
Java Program to Join Two Lists |
Java Program to Convert List (ArrayList) to Array and Vice-Versa |
Java Program to Get Current Working Directory |
Java Program to Convert Map (HashMap) to List |
Java Program to Convert Array to Set (HashSet) and Vice-Versa |
Java Program to Convert Byte Array to Hexadecimal |
Java Program to Create String from Contents of a File |
Java Program to Append Text to an Existing File |
Java Program to Convert a Stack Trace to a String |
Java Program to Convert File to byte array and Vice-Versa |
Java Program to Convert InputStream to String |
Java Program to Convert OutputStream to String |
Java Program to Lookup enum by String value |
Java Program to Compare Strings |
Java Program to Sort a Map By Values |
Java Program to Sort ArrayList of Custom Objects By Property |
Java Program to Check if a String is Numeric |
The process of Java programming can be simplified in three steps:
Java Programs or Java programming tutorial with examples of fibonacci series, armstrong number, prime number, palindrome number, factorial number, bubble sort. Java Programs or Java programming tutorial with examples of fibonacci series, armstrong number, prime number, palindrome number, factorial number, bubble sort, selection sort, insertion sort, swapping numbers etc. Write a java program to sort an array elements using selection sort algorithm. Input: 18 9 33 4 84 32. Output: 4 9 18 32 33 84. 3) Insertion Sort. Write a java program to sort an array elements using insertion sort algorithm. Input: 18 9 33 4 84 32. Output: 4 9 18 32 33 84. Java Searching Programs 1) Linear Search. Write a java program to perform linear search in java. Oct 08, 2018 Java Thread Example – extending Thread class. We can extend java.lang.Thread class to create our own java thread class and override run method. Then we can create it’s object and call start method to execute our custom java thread class run method. Here is a simple java thread example showing how to extend Thread class.
- Create the program by typing it into a text editor and saving it to a file – HelloWorld.java.
- Compile it by typing “javac HelloWorld.java” in the terminal window.
- Execute (or run) it by typing “java HelloWorld” in the terminal window.
Java Swing first programs. In this chapter we will use JFrame, JButton, and JLabel components. JFrame is is a top-level window with a title and a border. It is used to organize other components, commonly referred to as child components. JButton is a push button used to perform an action. JLabel is a component used to dispay a short text string or an image, or both.
Below given program is the simplest program of Java printing “Hello World” to the screen. Let us try to understand every bit of code step by step.
FileName : 'HelloWorld.java'. */ { // Prints 'Hello, World' to the terminal window. { } |
Output:
The “Hello World!” program consists of three primary components: the HelloWorld class definition, the
main
method and source code comments. Following explanation will provide you with a basic understanding of the code:- Class definition:This line uses the keyword class to declare that a new class is being defined.HelloWorld is an identifier that is the name of the class. The entire class definition, including all of its members, will be between the opening curly brace { and the closing curly brace } .
- main method: In Java programming language, every application must contain a
main
method whose signature is:Like in C/C++, main method is the entry point for your application and will subsequently invoke all the other methods required by your program. - The next line of code is shown here. Notice that it occurs inside main( ).This line outputs the string “Hello, World” followed by a new line on the screen. Output is actually accomplished by the built-in println( ) method. System is a predefined class that provides access to the system, and out is the variable of type output stream that is connected to the console.
- Comments: They can either be multi-line or single line comments.This is a multiline comment. This type of comment must begin with /* and end with */. For single line you may directly use // as in C/C++.
Important Points :
- The name of the class defined by the program is HelloWorld, which is same as name of file(HelloWorld.java). This is not a coincidence. In Java, all codes must reside inside a class and there is at most one public class which contain main() method.
- By convention, the name of the main class(class which contain main method) should match the name of the file that holds the program.
Simple Programs In Java
Compiling the program :
- After successfully setting up the environment, we can open terminal in both Windows/Unix and can go to directory where the file – HelloWorld.java is present.
- Now, to compile the HelloWorld program, execute the compiler – javac , specifying the name of the source file on the command line, as shown:
- The compiler creates a file called HelloWorld.class (in present working directory) that contains the bytecode version of the program. Now, to execute our program, JVM(Java Virtual Machine) needs to be called using java, specifying the name of the class file on the command line, as shown:This will print “Hello World” to the terminal screen.
In Windows
In Linux
The Department has been working with states to enhance their drivers licenses and identification documents to comply with travel rules under the Western Hemisphere Travel Initiative (WHTI), effective June 1, 2009. Enhanced drivers licenses make it easier for U.S. Citizens to cross the border into the United States because they include. Aug 10, 2012 An enhanced driver license (also known as a passport card) eases your ability to travel in and out of the United States by land and sea, doubling as a driver's license and passport. With it, no other documents are needed for proving citizenship and identity when entering the U.S. Or any other of the following participating Western Hemisphere Travel Initiative (WHTI) countries, territories. States with enhanced drivers license. Applying for an Enhanced Driver's License. Unfortunately, not all U.S. States (or Canadian provinces) issue EDLs—yet. The best way to find out if your state offers an enhanced driver's license (and get the state-specific application process and fees) is to check your state within our Applying for a New License section or contact your state's.
Ae expressions list. This article is contributed by Gaurav Miglani. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to [email protected]. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Sample Program In Java Using Inheritance
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.