Core java with examples

Core Java — Part 1

Welcome to the first part of three Core Java tutorials. In this series, we’ll discuss the basics of Core Java with practical examples. So let’s get started.

Java is an object-oriented programming language(OOPS). Sun Microsystems developed it in 1995, and it was later acquired by Oracle. It is secure and platform-independent, which means its compiled programs can be run on any operating system. We can run our Java programs on a wide variety of computers using a range of OS (macOS, Windows, Linux, etc.). This is possible because our Java program doesn’t execute directly on our computers. It runs on a standardized hypothetical computer known as Java Virtual Machine (JVM). This JVM is implemented in our computer by a program called Java interpreter. Don’t get confused by the terminology. We will discuss everything in detail. Let’s start with these terms.

  1. Java Virtual Machine (JVM) — It provides a runtime environment in which Java bytecode can be executed.
  2. Java Compiler — It compiles the .java file into bytecode. Bytecodes are binary instructions for Java interpreter.
  3. Java Interpreter — It reads the bytecode and converts it into machine code.
Читайте также:  Map iterations in java

NOTE — Java is platform-independent, but JVM is not. According to the OS, you need to install it into your machine.

Installation

Go to http s: //java. com / en /download/ and download the Java development toolkit(JDK) based on your OS.

After installation, set the path variable.

For Windows users, go to System Properties then Environment Variables . In system variable go to path and enter the path to the bin folder inside your JDK in the variable value. Click OK.

You can confirm that you have installed Java by opening the terminal and running javac command.

Compiling a Java Program —

The below command is used to compile a Java program —

javac is the compiler that compiles our program and creates a file with the extension . class The class file contains bytecodes that are binary instructions for Java interpreter.

To run application program —

The command below is used to run a Java program —

  • A Java program is a collection of one or more classes. There is at least one class in every program.
  • A Java program file must be saved with the .java extension.
  • We must save the program file with the same name as that of the class defined within it.
  • We must put the code for each public class in a separate file. (There can be only one public class in a file).

We will discuss what a class is and what is public in this series’s later parts.

Variables

A variable is known as a named value holder in primary memory. When a variable is declared, the compiler is able to check that it is not being used in a manner or context that is inappropriate to its type (type checking).

Example — int x = 10 ; Here x is a variable of integer type. We’ll discuss different data types later.

Variable Names

The name we choose for a variable is called an identifier, and an identifier can be of any length, although it must begin with a letter. The rest of the identifier can include digits. Operators and spaces are not allowed in identifiers. Java variables are case sensitive, which means name and NAME are two different identifiers.

We can’t use Java keywords as a name for something. Keywords are an essential part of the language and are meant for specific purposes.

Below are some examples of valid identifiers —

1 2 3 4 max, Max, MAX ab$123 $ab_123 _abcd 

Below are some examples of invalid identifiers —

1 2 3 4 5 6 7 ab + cd ab - cd ab @cd ab cd 123 abcd while final 

The last two while and final are reserved keywords.

In general, we follow camel case notation for variables, class, or method names in Java. Below is the example —

HelloWorld, calculateTotal, findMyAge().

That’s all for now for this part. We’ll continue in the next part with DataTypes, Type conversion, and more. Till then, happy coding 🙂

Источник

Core Java Tutorial Step By Step for Beginners

Scientech Easy

Welcome to the online core java tutorial point. Here, you can learn concepts of core java from basic to advanced levels.

This core java tutorial is specially designed for beginners and experienced. It will guide you step by step to learn every concept of the Java programming language.

We have taken great care not only to add a new tutorial but also thoroughly revise and update the existing content regularly so that you can get a better user experience.

If you are a beginner to learn Java programming, this may be the right platform. You can get an overview of the whole Core Java topics below with the link.

In each tutorial, you will also get interview questions and programming exercises to test your understanding.

Core Java tutorial

Core Java Tutorial

Start from here, to learn Java programming. I recommend you see these tutorials in the given order. Even if you have no prior knowledge of Java, you won’t face any difficulty understanding these tutorials.

Because we have covered each Java topic with real-time examples and programs in an easy way. Therefore, you will experience great in learning Java technology.

Java Introduction

  1. What is Java | Creation, History of Java
  2. Features of Java | Java Buzzwords
  3. What is JDK | Java Platform (Ecosystem)
  4. Bytecode in Java | Bytecode vs Machine code
  5. What is JRE | Java API, Class Loader
  6. What is JVM in Java | JVM Architecture, JIT Compiler
  7. What is Java Compiler | How works it
  8. Interpreter in Java | Interpreter vs Compiler
  9. Download and Install Java Development Kit (JDK) in Windows
  10. First Simple Java Program: Hello World
  11. Download and Install Eclipse IDE for Java Developers
  12. Write Simple Java Program in Eclipse IDE, Compile, Run
  13. C vs Java | 26 Vital Difference between C and Java
  14. C++ vs Java | 22 Vital Difference between C++ and Java

Basics of Java

Classes and Objects

Data Types and Variables

Java Operators

Decision Making, Branching, and Looping

  1. Conditional Control Statements in Java
  2. If Statement in Java | Example Program
  3. If-else in Java | Nested if-else, Example
  4. Loops in Java | Types: Nested, Infinite
  5. While Loop in Java | Example Program
  6. Java Do while loop
  7. For loop in Java
  8. Nested For loop in Java
  9. For each loop in Java | Enhanced for loop
  10. Switch Statement in Java | Example Program
  11. Java Break Statement
  12. Continue Statement in Java
  13. Labelled loop in Java | Example Program

Packages

Methods

Constructor

Modifiers

Blocks

Static and Final Keywords

Inner Classes

Object-oriented Programming System

Encapsulation

Inheritance

  1. Inheritance in Java | Realtime Example
  2. Superclass and Subclass in Java | Example Program
  3. Behavior of Access Modifiers in case of Inheritance
  4. Types of Inheritance in Java
  5. Top 10 Inheritance Interview Programs for Practice
  6. Class Relationships in Java
  7. Has-A Relationship
  8. Association in Java | Example Program
  9. Aggregation in Java | Example Program
  10. Composition in Java | Example Program
  11. Association vs Aggregation vs Composition

Super and This Keywords

Method Overloading

Method Overriding

Abstraction

Polymorphism

Exception Handling

  1. Exception Handling in Java | Realtime Example
  2. Exception Hierarchy in Java
  3. Checked and Unchecked Exceptions in Java
  4. Java Try Catch Block with Example
  5. Multiple Catch Block in Java
  6. Nested Try, Nested Try Catch in Java
  7. Finally Block in Java | Example Program
  8. Return Statement in Try-catch block
  9. When Finally block is not Executed
  10. Throw Keyword in Java | Example Program
  11. Throws Keyword in Java | Example Program
  12. User-defined Exception in Java with Example
  13. Chained Exceptions in Java
  14. Throwable class in Java
  15. Errors in Java | Runtime and Compile-time Errors
  16. Exception Handling Interview Programs for Practice

Collections Framework

String

Thread

Wrapper Class

Input and Output Stream

  1. Java IO Tutorial | Classes, Interfaces
  2. Stream in Java | Types, Example
  3. Stream Classes in Java | Byte Stream Classes
  4. CharacterStream Classes in Java
  5. FileInputStream Class in Java | Methods, Example
  6. FileOutputStream Class in Java | Methods, Example
  7. BufferedInputStream Class | Methods, Example
  8. BufferedOutputStream Class | Methods, Example
  9. FilterInputStream Class | Methods, Example
  10. FilterOutputStream Class | Methods, Example
  11. DataInputStream Class | Methods, Example
  12. DataOutputStream Class | Methods, Example
  13. SequenceInputStream Class | Methods, Example
  14. PrintStream in Java | Methods, Example
  15. PushbackInputStream in Java
  16. RandomAccessFile in Java | Methods, Example
  17. Reader Class in Java | Methods, Example
  18. InputStreamReader in Java | Methods, Example
  19. FileReader in Java with Example
  20. BufferedReader in Java | Methods, Example
  21. Writer in Java | Writer Class, Methods
  22. OutputStreamWriter in Java | Methods, Example
  23. FileWriter in Java | Example Program
  24. BufferedWriter in Java | Example Program
  25. PrintWriter in Java | Example Program
  26. Scanner Class in Java | Methods, Example
  27. Console in Java with Example Program
  28. File in Java | File Class, Example
  29. How to create a File in Java easily
  30. How to read a text file in Java
  31. How to write a file in Java
  32. How to take input in Java from user or keyboard
  33. Output formatting in Java using printf() and format()

Java Object Input and Output

Java Arrays

  1. Arrays in Java | Declaration, Example
  2. Array Initialization in Java with Example
  3. One Dimensional Array in Java with Example
  4. Multidimensional Array in Java | 2D Array, Example
  5. Three Dimensional Array in Java | 3D Array, Example
  6. Passing Arrays to Methods in Java
  7. How to Return Array in Java from a Method
  8. Arrays Class in Java | Methods, Example
  9. Array Copy in Java with Example Program
  10. Linear Array Search | Example Program
  11. Binary Search in Java for Sorted Array
  12. Sorting Array in Java with Example Program
  13. Arrays of Objects in Java with Example Program

Annotations

Garbage Collection

Generics

Miscellaneous Tutorials

Hope that this core java tutorial point has covered all tutorials step by step with basic and advanced example programs. I hope that you will have understood the concepts of core java and enjoyed all the example programs covered in tutorials.

If you’re interested in building a complete software development profile, then you should go for OdinSchool’s Full-Stack Software Development Course, which comes with industry aligned curriculum and 6 months additional placement assistance.

If you find anything incorrect in these tutorials, please inform to Scientech Easy team via email. Your email will be valuable to us.
Thanks for reading.

Источник

Оцените статью