Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d7da836

Browse filesBrowse files
authored
Add files via upload
1 parent e433ff4 commit d7da836
Copy full SHA for d7da836

File tree

Expand file treeCollapse file tree

1 file changed

+89
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+89
-0
lines changed

‎JavaLecture6.java

Copy file name to clipboard
+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// package com.rit;
2+
3+
public class JavaLecture6 {
4+
5+
public static void main(String[] args) {
6+
7+
// Types of Languages
8+
// 1 - Statically-typed Languages (C/C++, Java, Scala, C#, Go, Rust, Dart, TS, Kotlin, ...)
9+
// - Type checking at compile time
10+
// 2 - Dynamically-typed Languages (PHP, Perl, Lua, R, Ruby, JS, Python, Julia, ...)
11+
// - Type checking at runtime
12+
13+
// Java Data Types
14+
// All Java Data-Types are separated into two groups:
15+
// 1 - Primitive types or Value types or Simple types
16+
// 2 - References types or Non-Primitive types or Object types or Complex types
17+
18+
// 1 - Primitive types (storing simple values)
19+
// - Java has 8 primitive data types. They can be divided into 4 groups:
20+
// - Integer Numbers: byte, short, int, long
21+
// - Floating-Point Numbers: float, double
22+
// - Logical Type: boolean
23+
// - Characters: char
24+
// - The most used primitive types are "int", "long", "double", "boolean", and "char".
25+
26+
// 2 - References types (storing complex structure/objects)
27+
// - String
28+
// - Objects
29+
// - Arrays
30+
// - Classes
31+
// - Interfaces
32+
33+
// Sizes and Ranges of Primitive types
34+
// boolean: It represents only 1-bit of information, but its size is not something that's precisely defined. true or false
35+
// byte: the size is 08-bits (1 byte ), the range is from -128 to 127
36+
// char: the size is 16-bits (2 bytes), the range is from 0 to 65536 (unsigned)
37+
// short: the size is 16-bits (2 bytes), the range is from -32768 to 32767
38+
// int: the size is 32-bits (4 bytes),
39+
// long: the size is 64-bits (8 bytes),
40+
// float: the size is 32-bits (4 bytes), approximately 6-7 significant decimal digits
41+
// double: the size is 64-bits (8 bytes), approximately 14-16 significant decimal digits
42+
43+
// Default Values of Primitive types
44+
// boolean - false
45+
// char - \u0000
46+
// byte, short, int, long - 0
47+
// float, double - 0.0
48+
49+
// Primitive types Variables
50+
byte age = 26;
51+
short s = 5569;
52+
int v1 = 712928;
53+
long v2 = 32_754_921L;
54+
long v3 = 4242L;
55+
56+
int decNum = 190;
57+
int octNum = 0457;
58+
int hexNum = 0xFA;
59+
int binNum = 0b1101;
60+
61+
int minInt = Integer.MIN_VALUE;
62+
int maxInt = Integer.MAX_VALUE;
63+
64+
float p1 = 424.42F;
65+
double p2 = 3523184.428d;
66+
double eps = 5e-3; // 5 * 10^(-3) = 0.0005
67+
// System.out.println(Double.SIZE); // 64-bits
68+
double minDbl = Double.MIN_VALUE;
69+
double maxDbl = Double.MAX_VALUE;
70+
71+
char ch = 'C';
72+
char b = 'a' + 1; // the 'b' character
73+
char d = 'b' + 2; // the 'd' character
74+
char ch1 = 101; // the 'e' character
75+
char ch2 = '\u0040'; // the '@' character
76+
77+
boolean r1 = true;
78+
boolean r2 = false;
79+
boolean r3 = 5 > 2;
80+
81+
// References types Variables
82+
String msg1 = "Java Programming ";
83+
String msg2 = new String("Hi Java String");
84+
String newStr = msg1.concat("for Android");
85+
System.out.println(newStr);
86+
87+
// Happy Learning :)
88+
}
89+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.