Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Java Reference Sheet Formatted

Code

Uploaded by

Hockey for life
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Java Reference Sheet Formatted

Code

Uploaded by

Hockey for life
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Programming Reference Sheet

1. Program Structure

Basic Structure of a Java Program:

public class ClassName {

public static void main(String[] args) {

// Your code goes here

2. Variable Declaration & Data Types

Data Type Description Example

int Stores integers (whole numbers). int age = 20;

double Stores decimal numbers. double price = 19.99;

boolean Stores true or false values. boolean isJavaFun = true;

String Stores text values (non-primitive). String name = "Krishiv";

3. Input/Output

Reading Input (using Scanner):

import java.util.Scanner;

Scanner scanner = new Scanner(System.in);

System.out.print("Enter an integer: ");

int number = scanner.nextInt();

Printing Output:
System.out.println("Hello, World!"); // prints with a new line

4. Types of Integer Operators

Operator What It Does

+ Adds integers or concatenates strings.

- Subtracts integers.

* Multiplies integers.

/ Divides integers, returns integer quotient.

% Returns remainder of division.

5. Conditional Operators

Operator Meaning Operator Meaning

== Equal >= More than or equal

!= Not equal <= Less than or equal

> More than && Logical AND

< Less than || Logical OR

You might also like