Qortora · Search · Indexed page

www.tutorialspoint.comFetched 2026-08-17T15:29:52Z

Java Tutorial

This Java tutorial has been written for beginners to advanced programmers who are striving to learn Java programming. We have provided numerous practical examples to explain the concepts in simple and easy steps.

Open original source · Full cached text

Java Tutorial Home Whiteboard Practice Code Graphing Calculator Online Compilers Articles Tools Categories Explore Categories Find the perfect tutorial for your learning journey Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories Tutorials Courses Jobs Login Java - Home Java - Overview Java - History Java - Features Java Vs. C++ JVM - Java Virtual Machine Java - JDK vs JRE vs JVM Java - Environment Setup Java - Hello World Program Java - Comments Java - Basic Syntax Java - Variables Java - Data Types Java - Type Casting Java - Unicode System Java - User Input Java - Date & Time Java Operators Java - Operators Java - Arithmetic Operators Java - Assignment Operators Java - Relational Operators Java - Logical Operators Java - Bitwise Operators Java Operator Precedence & Associativity Java - Unary Operators Java Control Statements Java - Decision Making Java - If Else Statement Java - Switch Statement Java - Loop Control Java - For Loop Java - For-Each Loop Java - While Loop Java - Do While Loop Java - Break Statement Java - Continue Statement Object Oriented Programming Java - OOPs Concepts Java - Object & Classes Java - Class Attributes Java - Class Methods Java - Methods Java - Variables Scope Java - Constructors Java - Access Modifiers Java - Inheritance Java - Aggregation Java - Polymorphism Java - Overriding Java - Method Overloading Java - Dynamic Binding Java - Static Binding Java - Instance Initializer Block Java - Abstraction Java - Encapsulation Java - Interfaces Java - Packages Java - Inner Classes Java - Static Class Java - Anonymous Class Java - Singleton Class Java - Wrapper Classes Java - Enums Java - Enum Constructor Java - Enum Strings Java Built-in Classes Java - Number Java - Boolean Java - Characters Java - Arrays Java - Multi-Dimensional Arrays Java - Final Arrays Java - Math Class Java File Handling Java - Files Java - Create a File Java - Write to File Java - Read Files Java - Delete Files Java - Directories Java - I/O Streams Java Error & Exceptions Java - Exceptions Java - try-catch Block Java - try-with-resources Java - Multi-catch Block Java - Nested try Block Java - Finally Block Java - throw Exception Java - Exception Propagation Java - Built-in Exceptions Java - Custom Exception Java - Chained Exception Java Multithreading Java - Multithreading Java - Thread Life Cycle Java - Creating a Thread Java - Starting a Thread Java - Joining Threads Java - Naming Thread Java - Thread Scheduler Java - Thread Pools Java - Main Thread Java - Thread Priority Java - Daemon Threads Java - Thread Group Java - Shutdown Hook Java Synchronization Java - Synchronization Java - Block Synchronization Java - Static Synchronization Java - Inter-thread Communication Java - Thread Deadlock Java - Interrupting a Thread Java - Thread Control Java - Reentrant Monitor Java Networking Java - Networking Java - Socket Programming Java - URL Processing Java - URL Class Java - URLConnection Class Java - HttpURLConnection Class Java - Socket Class Java - Generics Java Collections Java - Collections Java - Collection Interface Java Interfaces Java - List Interface Java - Queue Interface Java - Map Interface Java - SortedMap Interface Java - Set Interface Java - SortedSet Interface Java Data Structures Java - Data Structures Java - Enumeration Java Collections Algorithms Java - Iterators Java - Comparators Java - Comparable Interface in Java Advanced Java Java - Command-Line Arguments Java - Lambda Expressions Java - Sending Email Java - Applet Basics Java - Javadoc Comments Java - Autoboxing and Unboxing Java - File Mismatch Method Java - REPL (JShell) Java - Multi-Release Jar Files Java - Private Interface Methods Java - Inner Class Diamond Operator Java - Multiresolution Image API Java - Collection Factory Methods Java - Module System Java - Nashorn JavaScript Java - Optional Class Java - Method References Java - Functional Interfaces Java - Default Methods Java - Base64 Encode Decode Java - Switch Expressions Java - Teeing Collectors Java - Microbenchmark Java - Text Blocks Java - Dynamic CDS archive Java - Z Garbage Collector (ZGC) Java - Null Pointer Exception Java - Packaging Tools Java - Sealed Classes Java - Record Classes Java - Hidden Classes Java - Pattern Matching Java - Compact Number Formatting Java - Garbage Collection Java - JIT Compiler Java Miscellaneous Java - Recursion Java - Regular Expressions Java - Serialization Java - Strings Java - Process API Improvements Java - Stream API Improvements Java - Enhanced @Deprecated Annotation Java - CompletableFuture API Improvements Java - Marker Interface Java - Streams Java - Datetime Api Java 8 - New Features Java 9 - New Features Java 10 - New Features Java 11 - New Features Java 12 - New Features Java 13 - New Features Java 14 - New Features Java 15 - New Features Java 16 - New Features Java APIs & Frameworks JDBC Tutorial SWING Tutorial AWT Tutorial Servlets Tutorial JSP Tutorial Java Class References Java - Scanner Java - Arrays Java - Strings Java - Date Java - ArrayList Java - Vector Java - Stack Java - PriorityQueue Java - LinkedList Java - ArrayDeque Java - HashMap Java - LinkedHashMap Java - WeakHashMap Java - EnumMap Java - TreeMap Java - IdentityHashMap Java - HashSet Java - EnumSet Java - LinkedHashSet Java - TreeSet Java - BitSet Java - Dictionary Java - Hashtable Java - Properties Java - Collection Java - Array Java Useful Resources Java - Cheatsheet Java - Questions and Answers Java 8 - Questions and Answers Java - Quick Guide Java - Useful Resources Java - Discussion Java - Online Compiler Java - Examples Selected Reading UPSC IAS Exams Notes Developer's Best Practices Questions and Answers Online Resume Builder HR Interview Questions Computer Glossary Who is Who Home Java Java Tutorial Job Search PDF Version Quick Guide Resources Discussion This Java tutorial has been written for beginners to advanced programmers who are striving to learn Java programming. We have provided numerous practical examples to explain the concepts in simple and easy steps. This tutorial has been prepared and reviewed by experienced Java programmers at Tutorials Point, and the best effort has been put into making it useful for the students and Java developers. After completing this tutorial, you will find yourself at a moderate level of expertise in Java programming, from where you can elevate yourself to the next levels. What is Java? Java is a popular high-level,object-oriented programming language that was originally developed by Sun Microsystems and released in 1995. Currently, Java is owned by Oracle, and more than 3 billion devices run Java. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions ofUNIX. Today Java is being used to develop numerous types of software applications, including desktop apps, mobile apps, web apps, games, and much more. Java is a general-purpose programming language intended to let programmers Write Once, Run Anywhere (WORA). This means that compiled Java code can run on all platforms that support Java without the need to recompile. In this tutorial, you will learn everything about Java, starting from basics to advanced concepts such as overview, history, installations, basic input/output, conditional & control statements, arrays, classes, inheritances, method overloading & overriding, exception handling, and many more. Java First Example The first example in Java is to print "Hello, World!" on the screen. Let's have a quick look at the first examples in Java programming: public class MyFirstJavaProgram { /* This is my first java program. * This will print 'Hello, World!' as the output */ public static void main(String []args) { System.out.println("Hello, World!"); // prints Hello, World! } } Online Java Compiler Our Java programming tutorial provides various examples to explain the concepts. To compile and execute the given Java programming examples in your browser itself, we have provided Online Java Compiler. You can edit and run almost all the examples directly from your browser without the need to set up your development environment. Try to click the icon to run the following Java code to print conventional "Hello, World!" using Java Programming. Below code box allows you to change the value of the code. So, please try to change the value inside println() and run it again to verify the result. public class MyFirstJavaProgram { /* This is my first java program. * This will print 'Hello, World!' as the output */ public static void main(String []args) { System.out.println("Hello, World!"); // prints Hello, World! } } Java Features Java is a feature-rich language. Java is evolving continuously with every update, and updates are coming every six months. Following are some of the main features of the Java language: Object Oriented: Java is a pure object-oriented language, and everything in Java is an object. Java supports OOPS principles like Inheritance, Encapsulation, Polymorphism, Classes , and so on. Java itself can be extended as well, being based on an object model. Platform Independent: Java code is platform independent. A Java code is not compiled into machine-specific code; it is compiled into a platform-neutral byte code. This byte code is executed by JVM which runs the code on the underlying platform. This capability makes Java a Write Once Run Anywhere language. Easy To Learn: Java inherits features from C and C++, and developers can easily learn Java if they know any of the C or C++ languages. Even for someone new to computer languages, Java is very easy to learn from scratch. Secure: Java is secure by architecture. A developer is not required to directly interact with the underlying memory or operating system. Java provides automatic garbage collection, so developers are not required to worry about memory leaks, management, etc. Architectural-Neutral: Java byte code can be executed on any kind of processor. JRE automatically handles the code execution on different types of processors. Portable: A Java code written on a Windows machine can be executed without any code change on MacOS and vice versa. There is no need to make any operating system-specific code changes. Robust: Java is a very robust language with very strong compile-time error checks, strict type checking, and runtime exception handling. Multithreading: Java provides inbuilt support for multiprocessing and multithreading. Java provides thread handling, monitors, deadlock handling, racing conditions, etc. High Performance: Java, although being interpreted, is still very performant. The JIT(Just In Time) compilerhelps in improving performance. Distributed: Java is designed for distributed systems and is the most popular language for developing internet-based applications as the internet is a distributed environment. Java Applications Since Java supports object-oriented features and is platform-independent, it is extensively used in various fields. Listed below are a few areas where Java is used - Enterprise solutions Game development Secured web development Embedded systems Mobile application development Big Data Applications, and many more. Java Platforms (Editions) Platforms of Java are divided into four Java editions, which are − Java SE (Java Standard Edition): It is a standard edition that is used to develop and deploy portable code for desktop and server environments. Java EE (Java Enterprise Edition): It is an enterprise edition that is used to develop web applications. Java ME (Java Micro Edition): J2ME is used to develop mobile applications; it is a micro edition of Java. JavaFx: It is used to develop lightweight user interfaces for rich internet applications. Java Jobs & Opportunities Java is very in demand, and all the major companies are recruiting Java progra…