Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
38 views
Intro To Java
Intro to Java
Uploaded by
Viraat Sewraj
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Intro to Java For Later
Download
Save
Save Intro to Java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
38 views
Intro To Java
Intro to Java
Uploaded by
Viraat Sewraj
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Intro to Java For Later
Carousel Previous
Carousel Next
Save
Save Intro to Java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
‘2821, 9:26 PM Introduction to Java - GacksforGeeks Introduction to Java Difficulty Level : Basic © Last Updated : 05 Oct, 2021 JAVA was developed by James Gosling at Sun Microsystems Inc in the year 1991, later acquired by Oracle Corporation. It is a simple programming language. Java makes writing, compiling, and debugging programming easy. It helps to create reusable code and modular programs Javais a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible. A general-purpose programming language made for developers to write once run anywhere that is compiled Java code can run on all platforms that support Java. Java applications are compiled to byte code that can run on any Java Virtual Machine. The syntax of Java is similar to c/c++. Attention reader! Don't stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. History Java's history is very interesting. It is a programming language created in 1991. James Gosling, Mike Sheridan, and Patrick Naughton, a team of Sun engineers known as the Green team initiated the Java language in 1991, Sun Microsystems released its first public implementation in 1996 as Java 1.0. It provides no-cost -run-times on popular platforms. Javal.0 compiler was re-written in Java by Arthur Van Hoff to strictly 6 mply with its specifications. With the arrival of Java 2, new versions had multiple configurations built for different types of platforms. hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp sno‘2821, 9:26 PM Introduction to Java - GacksforGeeks In 1997, Sun Microsystems approached the ISO standards body and later formalized Java, but it soon withdrew from the process. At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System Today's tea: Your Price® tool and finda rate that wor SonarCloud YoU i eet r On November 13, 2006, Sun released much of its Java virtual machine as free, open- source software. On May 8, 2007, Sun finished the process, making all of its JVM's core code available under open-source distribution terms. The principles for creating java were simple, robust, secured, high performance, portable, multi-threaded, interpreted, dynamic, etc. James Gosling in 1995 developed Java, who is known as the Father of Java. Currently, Java is used in mobile devices, internet programming, games, e-business, etc. Java programming language is named JAVA. Why? After the name OAK, the team decided to give a new name to it and the suggested words were Silk, Jolt, revolutionary, DNA, dynamic, etc. These all names were easy to spell and fun to say, but they all wanted the name to reflect the essence of technology. In accordance with James Gosling, Java the among the top names along with Silk, and since java was a unique name so most of them preferred it Java is the name of an island in Indonesia where the first coffee(named java coffee) 3s produced. And this name was chosen by James Gosling while having coffee near nis office, Note that Java is just a name, not an acronym hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp 210‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks Java Terminology Before learning Java, one must be familiar with these common terms of Java 1. Java Virtual Machine(JVM): This is generally referred to as JVM. There are three execution phases of a program. They are written, compile and run the program * Writing a program is done by a java programmer like you and me. * The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes Java program as input and generates bytecode as output. * In the Running phase of a program, JVM executes the bytecode generated by the compiler. Now, we understood that the function of Java Virtual Machine is to execute the bytecode produced by the compiler. Every Operating System has a different JVM but the output they produce after the execution of bytecode is the same across all the operating systems. This is why Java is known as a platform-independent language. 2, Bytecode in the Development process: As discussed, the Javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. It is saved as .class file by the compiler. To view the bytecode, a disassembler like javap can be used. SonarCloud Continuous Java Code Quality & Code Security analysis. Start 3. Java Development Kit(JDK): While we were using the term JDK, when we learn out bytecode and JVM. So, as the name suggests, it is a complete Java development xit that includes everything including compiler, Java Runtime Environment (JRE), java hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp 30‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks debuggers, java docs, etc. For the program to execute in java, we need to install JDK on our computer in order to create, compile and run the java program 4, Java Runtime Environment (JRE): JDK includes JRE. JRE installation on our computers allows the java program to run, however, we cannot compile it. JRE includes a browser, JVM, applet supports, and plugins, For running the java program, a computer needs JRE. 5, Garbage Collector: In Java, programmers can't delete the objects. To delete or recollect that memory JVM has a program called Garbage Collector. Garbage Collectors can recollect the of objects that are not referenced. So Java makes the life of a programmer easy by handling memory management. However, programmers should be careful about their code whether they are using objects that have been used for a long time. Because Garbage cannot recover the memory of objects being referenced 6, ClassPath: The classpath is the file path where the java runtime and Java compiler look for class files to load. By default, JDK provides many libraries. If you want to include external libraries they should be added to the classpath. Primary/Main Features of Java 1. Platform Independent: Compiler converts source code to bytecode and then the JVM executes the bytecode generated by the compiler. This bytecode can run on any platform be it Windows, Linux, macOS which means if we compile a program on Windows, then we can run it on Linux and vice versa. Each operating system has a different JVM, but the output produced by all the OS is the same after the execution of bytecode. That is why we call java a platform-independent language 2. Object-Oriented Programming Language: Organizing the program in the terms of collection of objects is a way of object-oriented programming, each of which represents an instance of the class. The four main concepts of Object-Oriented programming are * Abstraction * Encapsulation * Inheritance 6 Polymorphism hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp 40‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks 3. Simple: Java is one of the simple languages as it does not have complex features like pointers, operator overloading, multiple inheritances, Explicit memory allocation 4, Robust: Java language is robust that means reliable. It is developed in such a way that it puts a lot of effort into checking errors as early as possible, that is why the java compiler is able to detect even those errors that are not easy to detect by another programming language. The main features of java that make it robust are garbage collection, Exception Handling, and memory allocation 5. Secure: In java, we don't have pointers, and so we cannot access out-of-bound arrays i.e it shows ArrayIndexOutOfBound Exception if we try to do so. That's why several security flaws like stack corruption or buffer overflow is impossible to exploit in Java. SonarCloud 6. Distributed: We can create distributed applications using the java programming language. Remote Method Invocation and Enterprise Java Beans are used for creating distributed applications in java. The java programs can be easily distributed on one or more systems that are connected to each other through an internet connection 7. Multithreading: Java supports multithreading. It is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of cPU 8. Portable: As we know, java code written on one machine can be run on another machine, The platform-independent feature of java in which its platform-independent 6 tecode can be taken to any platform for execution makes java portable 9. High Performance: Java architecturgis defined in such a way that it reduces overhead during the runtime and at conf: java uses Just In Time (JIT) compiler htpsslwn.geekstorgooks orgintroduction-tejavalretsbp sia‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks where the compiler compiles code on-demand basics where it only compiles those methods that are called making applications to execute faster. 10. Dynamic flexibility: Java being completely object-oriented gives us the flexibility to add classes, new methods to existing classes and even creating new classes through sub-classes. Java even supports functions written in other languages such as C, C+# which are referred to as native methods. 11, Sandbox Execution: Java programs run in a separate space that allows user to execute their applications without affecting the underlying system with help of a bytecode verifier. Bytecode verifier also provides additional security as it's role is to check the code for any violation access. 12. Write Once Run Anywhere: As discussed above java application generates ‘class’ file which corresponds to our applications(program) but contains code in binary format. It provides ease t architecture-neutral ease as bytecode is not dependent on any machine architecture. It is the primary reason java is used in the enterprising IT industry globally worldwide 13, Power of compilation and interpretation: Most languages are designed with purpose either they are compiled language or they are interpreted language. But java integrates arising enormous power as Java compiler compiles the source code to bytecode and JVM executes this bytecode to machine 0S-dependent executable code Example // Demo Java program // Importing classes from packages import java.io.*; // Wain class public class GFG { // Main driver method public static void main(string[] args) t // Print statement e System.out.println("Nelcone to Geeks forGeek: + + hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp eo‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks Output SonarCloud Continuous Java Code Quality & Code Security analysis. Start Welcone to GeeksforGeeks Explanation: 1, Comments: Comments are used for explaining code and are used in a similar manner in Java or C or C++. Compilers ignore the comment entries and do not execute them. Comments can be of a single line or multiple lines. Single ine Comments: Syntax: // Single Line comment Multi-line comments: Syntax: /* Multi line comments*/ 2. import java.io.*: This means all the classes of io package can be imported. Java io package provides a set of input and output streams for reading and writing data to files or other input or output sources. 3. class: The class contains the data and methods to be used in the program. Methods define the behavior of the class. Class GFG has only one method Main in JAVA. e static void Main(): static keyword tells us that this method is accessible without hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp m0 stantiating the class.‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks 5. void: keywords tell that this method will not return anything. The main() method is the entry point of our application 6. System.in: This is the standard input stream that is used to read characters from the keyboard or any other standard input device. 7. System.out: This is the standard output stream that is used to produce the result of a program on an output device like the computer screen 8. println(): This method in Java is also used to display text on the console. It prints the text on the console and the cursor moves to the start of the next line at the console. The next printing takes place from the next line Everything in java , is represented in Class as an object including the main functi on. = OG Q Data Structures Algorithms Interview Preparation Topic-wise Practice C++ Java Python Like 0 © rrevious Next > hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp ano‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks RECOMMENDED ARTICLES Page: 12 3 ()] Java | MIDI Introduction ()5, Introduction to Checkstyle Plugin 19, Jul18 for Checking Java Code Quality 26, 0ct21 (2. Introduction to Java Servets (6. Difference Between java.sql.Time, eaten java.sql.Timestamp and java.sql.Date in Java ree Singleton Design Pattern | 0 3 Introduction to Processing | Java 0 7 Introduction 15, May ().4,_ Introduction to Java NIO with (JQ. Introduction to Hibernate Examples Framework 09, Jun 20. 13, Mar 1 @eoe Article Contributed By : goelshubhangi3118 @goelshubhangi3i8 Vote for difficulty Current difficulty : Basic Easy | Normal Medium Hard | Expert improved By: — abhinavsiwachS01, solankimayank hitps:lwwn.gaeksforgeeks orglinttoduction-t-javalref=Ibp sito‘wiaai21, 9:27 PM Introduction to Java - GacksforGeeks Practice Tags: Java Writing code in comment? Please use ide,gocksforgecks,org, generate link and share the link here, oS GeeksforGeeks @ sthFloor, A-ne, Sector-136, Noida, Uttar Pradesh - 201305 ©
[email protected]
Company About Us Careers Privacy Policy Contact Us Copyright Policy Web Development Web Tutorials HTML css JavaScript Bootstrap Beene act 0900 Learn Algorithms Data Structures Languages CS Subjects Video Tutorials Contribute Write an Article Write Interview Experience Internships Videos sono
You might also like
Programme Specification: BSC (Hons) Information Technology
PDF
No ratings yet
Programme Specification: BSC (Hons) Information Technology
11 pages
All about Java
PDF
No ratings yet
All about Java
91 pages
JAVA1
PDF
No ratings yet
JAVA1
42 pages
Java notes
PDF
No ratings yet
Java notes
30 pages
Introduction to Java
PDF
No ratings yet
Introduction to Java
67 pages
Chap1-Introduction To Java
PDF
No ratings yet
Chap1-Introduction To Java
10 pages
Unit 1 Introduction to JAVA
PDF
No ratings yet
Unit 1 Introduction to JAVA
23 pages
UNIT 4.1
PDF
No ratings yet
UNIT 4.1
20 pages
Introduction To Java
PDF
No ratings yet
Introduction To Java
35 pages
Java Unit 1 Notes
PDF
No ratings yet
Java Unit 1 Notes
33 pages
CH - 1 - Introduction To Java
PDF
No ratings yet
CH - 1 - Introduction To Java
24 pages
Core Java Index
PDF
No ratings yet
Core Java Index
46 pages
File1-Unit-1 (Java Intro) - 1
PDF
No ratings yet
File1-Unit-1 (Java Intro) - 1
15 pages
Java Complete Tutorial
PDF
100% (2)
Java Complete Tutorial
599 pages
22cs202-Unit 1 - PPT
PDF
No ratings yet
22cs202-Unit 1 - PPT
153 pages
Chapter I - Intro
PDF
No ratings yet
Chapter I - Intro
9 pages
Java
PDF
No ratings yet
Java
426 pages
Java Fundamentals
PDF
No ratings yet
Java Fundamentals
18 pages
What Is Java
PDF
No ratings yet
What Is Java
20 pages
UNIT-1 Introduction - NOTES Java
PDF
No ratings yet
UNIT-1 Introduction - NOTES Java
44 pages
Project File
PDF
No ratings yet
Project File
52 pages
Object Oriented Programming Using Java
PDF
No ratings yet
Object Oriented Programming Using Java
267 pages
Sybsc It - Core Java - Unit I
PDF
No ratings yet
Sybsc It - Core Java - Unit I
72 pages
JAVA DAY 1
PDF
No ratings yet
JAVA DAY 1
12 pages
Core Java
PDF
No ratings yet
Core Java
550 pages
java
PDF
No ratings yet
java
30 pages
Installing Eclipse
PDF
No ratings yet
Installing Eclipse
236 pages
Java Tutorial
PDF
No ratings yet
Java Tutorial
145 pages
Introduction To Java
PDF
No ratings yet
Introduction To Java
12 pages
OOP UNIT1 P2
PDF
No ratings yet
OOP UNIT1 P2
19 pages
DCIT 22 Computer Programming 1 Lecture 3
PDF
No ratings yet
DCIT 22 Computer Programming 1 Lecture 3
22 pages
KCA 202 OOP Unit 1 - 240429 - 111726
PDF
No ratings yet
KCA 202 OOP Unit 1 - 240429 - 111726
24 pages
JAVA
PDF
No ratings yet
JAVA
43 pages
Co 1
PDF
No ratings yet
Co 1
123 pages
Demystifying Java
PDF
No ratings yet
Demystifying Java
22 pages
Introduction to Java
PDF
No ratings yet
Introduction to Java
15 pages
JAVA Notes-1 PDF
PDF
No ratings yet
JAVA Notes-1 PDF
122 pages
Introduction To Programming
PDF
No ratings yet
Introduction To Programming
48 pages
Java Tpoint
PDF
75% (4)
Java Tpoint
259 pages
Java 2
PDF
No ratings yet
Java 2
371 pages
Introduction of Java Report
PDF
100% (5)
Introduction of Java Report
35 pages
Java Notes
PDF
No ratings yet
Java Notes
27 pages
Chapter 2-Introduction To Java
PDF
No ratings yet
Chapter 2-Introduction To Java
31 pages
Javatot
PDF
No ratings yet
Javatot
180 pages
JNTUK R19 B.Tech ECE 2-1 OOPT Java Unit 1 Notes
PDF
No ratings yet
JNTUK R19 B.Tech ECE 2-1 OOPT Java Unit 1 Notes
59 pages
Introduction To Java, Its History and Features
PDF
No ratings yet
Introduction To Java, Its History and Features
3 pages
Class IX Chapter 2
PDF
No ratings yet
Class IX Chapter 2
36 pages
What Is Java Lecture1
PDF
No ratings yet
What Is Java Lecture1
14 pages
Core Java
PDF
No ratings yet
Core Java
27 pages
Java
PDF
No ratings yet
Java
11 pages
01 Java Introduction To Java
PDF
No ratings yet
01 Java Introduction To Java
44 pages
Java Tutorial
PDF
No ratings yet
Java Tutorial
35 pages
Project of DBMS
PDF
No ratings yet
Project of DBMS
48 pages
Introduction To JAVA
PDF
No ratings yet
Introduction To JAVA
24 pages
Java Notes
PDF
No ratings yet
Java Notes
17 pages
Unit 1 - Java
PDF
No ratings yet
Unit 1 - Java
57 pages
Chap1introduction To Java
PDF
No ratings yet
Chap1introduction To Java
13 pages
Day1 Javaintro
PDF
No ratings yet
Day1 Javaintro
31 pages
Java-Ref. Notes
PDF
No ratings yet
Java-Ref. Notes
59 pages
Zlib Alternatives1
PDF
No ratings yet
Zlib Alternatives1
6 pages
Zlib Alternatives
PDF
No ratings yet
Zlib Alternatives
25 pages
Const
PDF
No ratings yet
Const
7 pages
Scanf Issue2
PDF
No ratings yet
Scanf Issue2
2 pages
Scanf Issue1
PDF
No ratings yet
Scanf Issue1
2 pages
Differences Between JDK, JRE and JVM
PDF
No ratings yet
Differences Between JDK, JRE and JVM
8 pages
Extern Keyword
PDF
No ratings yet
Extern Keyword
5 pages
Java Hello World Program
PDF
No ratings yet
Java Hello World Program
8 pages
How JVM Works - JVM Architecture
PDF
No ratings yet
How JVM Works - JVM Architecture
11 pages
Masters Module Organisation
PDF
No ratings yet
Masters Module Organisation
1 page
Pattern Recognition and Machine Learning
PDF
No ratings yet
Pattern Recognition and Machine Learning
16 pages
Programme Specification: Mcomp Information Technology
PDF
No ratings yet
Programme Specification: Mcomp Information Technology
10 pages
The New Revised 20-Point Scale Grading System
PDF
No ratings yet
The New Revised 20-Point Scale Grading System
7 pages
Difference Between ++i and I++
PDF
No ratings yet
Difference Between ++i and I++
2 pages
FAQ Download Files PDF
PDF
No ratings yet
FAQ Download Files PDF
4 pages
Common Ways To Say Hello in Greece - GreekPod101
PDF
No ratings yet
Common Ways To Say Hello in Greece - GreekPod101
8 pages
Coronavirus PDF
PDF
No ratings yet
Coronavirus PDF
5 pages
Configuring Vlan 1 For Switch Management
PDF
No ratings yet
Configuring Vlan 1 For Switch Management
8 pages
What Type of A Leader Are You - Describe Your Leadership Style
PDF
No ratings yet
What Type of A Leader Are You - Describe Your Leadership Style
4 pages