Skip to content

This repository contains programs in the Java programming language.

Notifications You must be signed in to change notification settings

madhurimarawat/Java-Programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java-Programming

This repository contains programs in the Java programming language.


About Java Programming

--> Java is a widely-used, high-level, object-oriented programming language.

--> Known for its platform independence, which allows programs to run on any platform with a Java Virtual Machine (JVM).

--> Originally developed by James Gosling at Sun Microsystems (now owned by Oracle Corporation).

--> Java code is typically written in text files with a .java extension.


Mode of Execution Used: Visual Studio Code   JDK

Visual Studio Code

--> Visit the official website:  Visual Studio Code

--> Download according to the platform that will be used like Linux, Macos or Windows.

--> Follow the setup wizard.

--> Create a new file with the extention of .java and then this file can be executed using java.

Java

--> Visit the official website of Java: https://www.java.com/en/

--> Download according to the platform that is going to be used.

--> After downloading, load the executble file and follow along the process.

Java Developement Kit

--> Visit the official website of Oracle: https://www.java.com/en/](https://www.oracle.com/java/technologies/downloads/

--> Download according to the platform that is going to be used.

--> After downloading, load the executable file and follow along the process.

Executing Java Code

--> Open the command prompt in the working directory of java code file.

--> First the java code file is executed using java compiler with the following command:-

javac java-codefile.java

where java-codefile.java is the name of java code file. Make sure the name of class and code file is same else it gives error.

--> Now if this will run successfully a class file with the same name as code file will be saved in the directory.

--> Now run the following command to get output :-

java java-codefile

where java-codefile.java is the name of java code file. Also we do not need to mention extention here.


Java Programming Features

  • Strongly typed and statically compiled language.
  • Automatic memory management via garbage collection.
  • Rich standard library and extensive ecosystem of libraries and frameworks.
  • Multi-threading support for concurrent programming.
  • Exception handling for robust error management.
  • Object-oriented principles like inheritance and polymorphism.

--> Syntax and Structure

  • Java programs consist of classes.
  • A class defines data (fields/variables) and methods (functions).
  • The public static void main(String[] args) method is the entry point for execution.
  • Statements end with a semicolon (;).

--> Data Types

  • Primitive data types: int, double, char, boolean, etc.
  • Reference data types: String, arrays, user-defined classes.

--> Control Structures

  • if, else if, and else for conditional branching.
  • for, while, and do-while for loops.
  • switch for multi-branch decision-making.

--> Object-Oriented Programming

  • Classes and objects for code organization.
  • Inheritance, encapsulation, and polymorphism principles.
  • Constructors and destructors.

--> Exception Handling

  • try, catch, finally blocks for error handling.
  • Throwing and catching exceptions.

--> Garbage Collection

  • Automatic memory management for freeing unused objects.
  • Helps prevent memory leaks leading to better memory management.

--> Platform Independence

  • Compiled Java bytecode runs on any platform with a compatible JVM(Java Virtual Machine).
  • This makes java a platform independent programming languge.