JEAD
Java Compiler
Session 6-7:
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Java Compiler
• ‘javac’:
o Checks for Syntax errors
o Converts .java file to .class intermediate file (byte code)
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Execution of Java Program
• Execute .class files (without extension)- java
• ‘java’ - JVM
loads the class file specified
Calls main() method for execution
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Data types
Data types in programming define the type of data that a
variable can hold. They specify the kind of value a variable can
store and how it can be manipulated. Understanding data
types is fundamental because they dictate the operations that
can be performed on the data and how the data is stored in
memory.
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Data types
• Numbers : byte, short, int, long (default: 0)
• Decimal: float and double (default: 0.0) – difference??
• Character: char (default: ‘ ‘)
• Boolean : False
• Non-primitive – builtin class - String
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Java Input statements
• Scanner class
• BufferedReader
• BufferedReader + InputStreamReader
Class Assignment:
Find the difference between the above classes.
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Java Input statements
public class DataTypesDemo {
public static void main(String[] args) {
// Primitive data types
byte byteValue = 127; // 8-bit signed integer
short shortValue = 32000; // 16-bit signed integer
int intValue = 123456789; // 32-bit signed integer
long longValue = 123456789L; // 64-bit signed integer
float floatValue = 3.14f; // 32-bit floating-point
double doubleValue = 3.14159265359; // 64-bit floating-point
char charValue = 'A'; // 16-bit Unicode character
boolean booleanValue = true; // Boolean value
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Java Input statements
// Displaying primitive data types
System.out.println("Primitive Data Types:");
System.out.println("byte: " + byteValue);
System.out.println("short: " + shortValue);
System.out.println("int: " + intValue);
System.out.println("long: " + longValue);
System.out.println("float: " + floatValue);
System.out.println("double: " + doubleValue);
System.out.println("char: " + charValue);
System.out.println("boolean: " + booleanValue);
- Santosh Katti, Department of Computer Applications, PESU
JEAD
Java Input statements
// Reference data types
String stringValue = "Hello, World!"; // String object
int[] intArray = {1, 2, 3, 4, 5}; // Array of integers
// Displaying reference data types
System.out.println("\nReference Data Types:");
System.out.println("String: " + stringValue);
System.out.print("Array: ");
for (int i : intArray) {
System.out.print(i + " "); } }
}
- Santosh Katti, Department of Computer Applications, PESU