Skip to main content

About JAVA with details

 Sure, I can provide you with a concise Java cheat sheet. Here are some key points:


1. **Hello World**:

```java

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello, World!");

    }

}

```


2. **Variables**:

```java

int age = 25;

double price = 19.99;

String name = "John";

boolean isTrue = true;

```


3. **Conditional Statements**:

```java

if (condition) {

    // Code block executed if the condition is true

} else if (anotherCondition) {

    // Code block executed if anotherCondition is true

} else {

    // Code block executed if none of the above conditions are true

}

```


4. **Loops**:

```java

for (int i = 0; i < 5; i++) {

    // Code block executed 5 times

}


while (condition) {

    // Code block executed while the condition is true

}


do {

    // Code block executed at least once, then repeatedly while the condition is true

} while (condition);

```


5. **Arrays**:

```java

int[] numbers = {1, 2, 3, 4, 5};

String[] fruits = new String[3];

fruits[0] = "Apple";

fruits[1] = "Banana";

fruits[2] = "Orange";

```


6. **Methods**:

```java

public int add(int a, int b) {

    return a + b;

}

```


7. **Classes and Objects**:

```java

public class Car {

    String make;

    String model;


    public Car(String make, String model) {

        this.make = make;

        this.model = model;

    }

}


Car myCar = new Car("Toyota", "Corolla");

```


8. **Inheritance**:

```java

public class Animal {

    void sound() {

        System.out.println("Animal makes a sound");

    }

}


public class Dog extends Animal {

    void sound() {

        System.out.println("Dog barks");

    }

}

```


9. **Exception Handling**:

```java

try {

    // Code that may throw an exception

} catch (ExceptionType e) {

    // Code to handle the exception

} finally {

    // Code that runs regardless of whether an exception was thrown

}

```


10. **Interfaces**:

```java

interface Shape {

    void draw();

}


class Circle implements Shape {

    public void draw() {

        // Code to draw a circle

    }

}

```


Remember, this is just a concise overview. Java is a vast language with many features, but this cheat sheet should cover the basics to get you started. If you have any specific questions or need more details, feel free to ask!

Comments

Popular posts from this blog

Gujarati Keyboard layout (terafont-varun), Computer Short cut key, Tally short cut key

Terafont-Varun (Gujarati Typing) Keyboard Layout by "Sama Soyab"

  For Gujarati Typing : Required : Terafont-Varun Font  After Successfully Installed Terafont Varun Open Any Text Editor or any program. Select Font Terafont-Varun -> Ok For more detail please watch below video. Search Topics : Learn terafont varun, Learn terafont chandan, Learn terafont gujarati to english translation, Learn terafont varun keyboard, Learn terafont converter, Learn terafont varun zip, Learn terafont keyboard, Learn terafont kinnari, Learn terafont akash, Learn terafont aakash, Learn terafont akash ttf, Learn terafont aakash gujarati download, Learn terafont akash keyboard, Learn terafont akash download for windows 10, Learn terafont akash font download, Learn terafont arun, Learn terafont border, Learn terafont chandan keyboard, Learn terafont-chandan font, Learn tera font chandana, Learn convert terafont to shruti, Learn convert terafont varun to shruti, Learn terafont varun chart, Learn terafont download, Learn terafont download for windows 10, Learn terafont down

Word , Excel , Power Point Shortcut Key in Gujarati