Java Programming: Constants, Variables, and Data Types, Lecture notes of Java Programming

An introduction to Java programming concepts, focusing on constants, variables, and data types. Constants are values that do not change, declared using the 'final' keyword and assigned a datatype. Variables are storage locations for values, declared with a datatype and can be assigned values using assignment statements. Data types include numerical types, and the document covers type casting, both implicit and explicit.

Typology: Lecture notes

2020/2021

Uploaded on 04/10/2021

sarath78421
sarath78421 🇮🇳

1 document

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CONSTANTS,
VARIABLES
AND
DATA TYPES
pf3
pf4
pf5

Partial preview of the text

Download Java Programming: Constants, Variables, and Data Types and more Lecture notes Java Programming in PDF only on Docsity!

CONSTANTS,

VARIABLES

AND

DATA TYPES

Constants

Constants do not change final datatype CONSTANTNAME = VALUE; final double PI = 3.14159; final int SIZE = 3;

Assignment Statements

x = 1; // Assign 1 to x; radius = 1.0; // Assign 1.0 to radius; a = 'A'; // Assign 'A' to a;

Data Types

Type Casting

Implicit casting double d = 3 ; (type widening) Explicit casting int i = (int) 3. 0 ; (type narrowing) int i = (int)3.9; (Fraction part is truncated)