0% found this document useful (0 votes)
5 views4 pages

Java Notes

The document provides an overview of Java programming language concepts, focusing on variables and data types. It explains different types of variables (local, instance, static), their syntax, and examples of various data types such as integer, float, char, boolean, and string. Additionally, it covers input methods and basic output formatting, including the use of loops in Java.

Uploaded by

Elvis Dasco
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Java Notes

The document provides an overview of Java programming language concepts, focusing on variables and data types. It explains different types of variables (local, instance, static), their syntax, and examples of various data types such as integer, float, char, boolean, and string. Additionally, it covers input methods and basic output formatting, including the use of loops in Java.

Uploaded by

Elvis Dasco
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA PROGRAMMING LANGUAGE

DCIT 23 - SECOND SEMESETER


VARIABLE DATA TYPES
●​ VARIABLE ●​ DATA TYPES
○​ Containers used for storing values. ○​ Is an specifier that allocates different
○​ Memory location name of the data. sizes and types of values that can be
○​ When proper naming a variable you stored in the variable
cannot create a name that starts ○​ Also serves as a rule to limit the type
with of values being accepted to a
■​ NUMBERS variable.​
■​ SPECIAL CHARACTERS
■​ RESERVED WORDS (syntax or ●​ SYNTAX (FORMAT)
data types) ○​ DataType VariableName = value;
●​ TYPES OF VARIABLE ○​ Example:
○​ Local Variables ■​ Int KarmaMeter = 99;
○​ Instance Variables ●​ DATA TYPES
○​ Static Variables ○​ INTEGER (int)
●​ STATIC VARIABLE ■​ Whole numbers
○​ May syntax na static kasama ng ■​ int KarmaMeter = 99;​
data type and value
○​ EXAMPLE: ○​ FLOATING POINT (float)
class Sample { ■​ Decimal numbers
static int grades = 1; ■​ float KarmaMeter = 9.9;​

}
○​ CHARACTER (char)
●​ INSTANCE VARIABLE
■​ Single Letter or Number
○​ Type of variable na naka declare
(Character/Single String)
outside of a method
■​ char KarmaMeter = ‘T’;​
○​ Declaration or Global Variable
○​ Variables that can be accessed with
○​ BOOLEAN (boolean)
different methods inside the project
■​ True or False
or class
■​ boolean KarmaMeter = true;​
○​ EXAMPLE:
class Sample { ○​ STRING (String)
int grades = 99; ■​ Characters enclosed in
} quotation marks.
■​ String KarmaMeter =
●​ LOCAL VARIABLE
“MasamaUgali”;
○​ Variable that is only accessible
within a certain method (may range
lang) ●​ INPUT DATA
○​ EXAMPLE: ○​ Input data from the user's preference
class Sample {
void method () {
int grades = 96;
​ }
}
JAVA PROGRAMMING LANGUAGE
DCIT 23 - SECOND SEMESETER
●​ INTEGER INPUT
○​ Reads the next integer value
○​ Example:

●​ FLOAT INPUT
○​ Reads the next floating point
(decimal) value
○​ Example: ○​ OUTPUT:

●​ DOUBLE INPUT ●​ PRINTING STRING WITH LN (SOUT + TAB)


○​ Reads the next double (large ○​ Print the output in different line
decimal) value.
○​ Example:

●​ LINE INPUT
○​ Reads the entire line of input,
including spaces, until Enter is
pressed.
○​ Example: ○​ OUTPUT:

●​ BOOLEAN INPUT
○​ Reads a boolean value (true or
false). BASIC INPUT
○​ Example:
●​ BASIC USER INPUT
○​ Always use scanner class to use
input
●​ LONG INPUT ○​ Always check data type (dapat
○​ Reads the next long (large integer) same lagi when using input type)
value. ○​ Print the output in one line
○​ Example:

●​ NEXT INPUT
○​ Reads the next single word until a
○​ EXPECTED OUTPUT:
whitespace is encountered.
○​ Example:

BASIC OUTPUT
●​ PRINTING STRING WITHOUT LN
○​ Print the output in one line
JAVA PROGRAMMING LANGUAGE
DCIT 23 - SECOND SEMESETER
STRING FORMATTING ●​ DISPLAYING PRECISION VALUE
●​ DISPLAYING STRING VALUE (%s) (%.(value/number kung ilang place gusto
○​ code: iround off)f))
○​ code:

○​ output:

○​ output:

●​ DISPLAYING INTEGER VALUE (%d)


○​ code:

○​ output:

●​ DISPLAYING FLOAT VALUE (%f)


○​ code:

○​ output:

●​ DISPLAYING WIDTH VALUE


(%.(value/number kung ilang place)f))
○​ code:

○​ output:
JAVA PROGRAMMING LANGUAGE
DCIT 23 - SECOND SEMESETER
FOR LOOP
●​ FOR LOOP SYNTAX
○​ Counter
○​ Condition
○​ Increment/Decrement

●​ PROPER SYNTAX:
○​ for (counter; condition; i++) {
​ statements;
}

You might also like