Skip to content

Commit b43e485

Browse files
committed
Migrate development environment from Windows to macOS and continue project updates
- Shifted primary development environment from Windows to macOS to ensure better performance, stability, and streamlined workflow for Java development. - Removed OS-specific metadata and ensured platform-agnostic project compatibility. - Normalized line endings to LF for cross-platform consistency. - Verified and adjusted file paths, permissions, and encoding settings to suit macOS environment. - Cleaned up unnecessary Windows-generated files and updated Git configuration accordingly. - Future commits and development will now be managed entirely from macOS. This migration ensures a cleaner, more consistent setup moving forward and prepares the project for scalable development across Unix-based systems. Future development will continue on macOS for a smoother, Unix-based experience. Signed-off-by: Someshdiwan <[email protected]>
1 parent 21573cd commit b43e485

File tree

28 files changed

+705
-52
lines changed

28 files changed

+705
-52
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@echo off
2+
pushd "%~dp0"
3+
4+
:MENU
5+
cls
6+
echo =========================================================
7+
echo Java Exception Handling - Helpful Links
8+
echo =========================================================
9+
echo 1. What Is an Exception? (Oracle Tutorial)
10+
echo 2. NullPointerException Class (Java SE 8 API)
11+
echo 3. java.lang Package Summary (Java SE 8)
12+
echo 4. Full Exceptions Tutorial (Oracle Docs)
13+
echo 5. Exit
14+
echo.
15+
set /p choice=Enter your choice [1-5]:
16+
17+
if "%choice%"=="1" start https://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html & goto MENU
18+
if "%choice%"=="2" start https://docs.oracle.com/javase/8/docs/api/java/lang/NullPointerException.html & goto MENU
19+
if "%choice%"=="3" start https://docs.oracle.com/javase/8/docs/api/java/lang/package-summary.html#package.description & goto MENU
20+
if "%choice%"=="4" start https://docs.oracle.com/javase/tutorial/essential/exceptions/ & goto MENU
21+
if "%choice%"=="5" goto END
22+
23+
echo.
24+
echo Invalid choice. Please select a number from 1 to 5.
25+
pause
26+
goto MENU
27+
28+
:END
29+
echo Goodbye!
30+
pause
31+
32+
popd
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
pushd "%~dp0"
3+
4+
:MENU
5+
cls
6+
echo ================================================
7+
echo Java SE Documentation - Exception Class
8+
echo ================================================
9+
echo 1. Open Exception Class Documentation
10+
echo 2. Exit
11+
echo.
12+
set /p choice=Enter your choice [1-2]:
13+
14+
if "%choice%"=="1" start https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Exception.html & goto MENU
15+
if "%choice%"=="2" goto END
16+
17+
echo.
18+
echo Invalid choice. Please select 1 or 2.
19+
pause
20+
goto MENU
21+
22+
:END
23+
echo Goodbye!
24+
pause
25+
26+
popd
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class NegativeValueExceptionDemo
2+
{
3+
public static void main (String[] args)
4+
{
5+
try {
6+
int length = -5;
7+
int width = 3;
8+
9+
// Call the static method directly using the class name
10+
int area = Rectangle.calculateArea(length, width);
11+
System.out.println("Area: " + area);
12+
}
13+
catch (NegativeValueException e) {
14+
System.out.println(e.getMessage());
15+
}
16+
}
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class DemoThread {
2+
public static void main(String[] args) {
3+
A a = new A();
4+
B b = new B();
5+
6+
a.start(); // starts thread A
7+
b.start(); // starts thread B
8+
}
9+
}
10+
11+
class A extends Thread {
12+
public void run() {
13+
for (int i = 0; i < 10; i++) {
14+
System.out.println("From class A");
15+
}
16+
}
17+
}
18+
19+
class B extends Thread {
20+
public void run() {
21+
for (int i = 0; i < 10; i++) {
22+
System.out.println("From class B");
23+
}
24+
}
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
pushd "%~dp0"
3+
4+
:MENU
5+
cls
6+
echo ===============================================
7+
echo Oracle Java Article - Reflection API
8+
echo ===============================================
9+
echo 1. Open Java Reflection Article
10+
echo 2. Exit
11+
echo.
12+
set /p choice=Enter your choice [1-2]:
13+
14+
if "%choice%"=="1" start https://www.oracle.com/technical-resources/articles/java/javareflection.html & goto MENU
15+
if "%choice%"=="2" goto END
16+
17+
echo.
18+
echo Invalid choice. Please select 1 or 2.
19+
pause
20+
goto MENU
21+
22+
:END
23+
echo Goodbye!
24+
pause
25+
26+
popd
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
public class WrapperClassesDemo
2+
{
3+
public static void main(String[] args)
4+
{
5+
//Some primitive types
6+
char letter = 'A';
7+
boolean value = true;
8+
int intNum = -269;
9+
double floatNum = Math.pow(2,2); // 2 to the 2 is 4
10+
11+
//Converting them into objects via their wrapper classes
12+
Character Letter = (Character) letter;
13+
Boolean Value = (Boolean) value;
14+
Integer IntNum = (Integer) intNum;
15+
Double FloatNum = (Double) floatNum;
16+
17+
//Wrapper objects print their value just fine
18+
System.out.println("" + Letter + " " + Value + " " + IntNum + " " + FloatNum);
19+
20+
//Some Numerical objects
21+
Long Num1 = 987L;
22+
Float Num2 = 34.56f;
23+
24+
//Turning them into primitive types
25+
long num1 = (long) Num1;
26+
float num2 = (float) Num2;
27+
28+
System.out.println("" + num1 + " " + num2);
29+
}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="jdk" jdkName="openjdk-23" jdkType="JavaSDK" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

Section23JavaIOStreams/Section23JavaIOStreams.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<content url="file://$MODULE_DIR$">
66
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
77
</content>
8-
<orderEntry type="inheritedJdk" />
8+
<orderEntry type="jdk" jdkName="openjdk-23" jdkType="JavaSDK" />
99
<orderEntry type="sourceFolder" forTests="false" />
1010
</component>
1111
</module>

Section23JavaIOStreams/Serialisation Storing Data in a File/src/PrintInputStreamExample.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import java.io.*;
22

3-
class PrintInputStreamExample
4-
{
5-
public static void main(String[] args) throws Exception
6-
{
7-
FileInputStream fis=new FileInputStream("C:\\Users\\somes\\Downloads\\JAVA SE\\Section23JavaIOStreams\\Serialisation Storing Data in a File\\MyJAVA\\Student1.txt");
3+
class PrintInputStreamExample {
4+
public static void main(String[] args) throws Exception {
5+
FileInputStream fis = new FileInputStream("C:\\Users\\somes\\Downloads\\JAVA SE\\Section23JavaIOStreams\\Serialisation Storing Data in a File\\MyJAVA\\Student1.txt");
86
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
97

108
// Creating a Student object

Section24JavaGenerics/src/Generics in Java introduce parameterized types.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,30 @@ Programs that use Generics has got many benefits over non-generic code.
5858

5959
2. Type Safety: Generics make errors to appear compile time than at run time (It’s always better to know problems in your code at compile time rather than making your code fail at run time).
6060

61-
Suppose you want to create an ArrayList that store name of students, and if by mistake the programmer adds an integer object instead of a string, the compiler allows it. But, when we retrieve this data from ArrayList, it causes problems at runtime.
61+
Suppose you want to create an ArrayList that store name of students, and if by mistake the programmer adds an integer object instead of a string, the compiler allows it. But, when we retrieve this data from ArrayList, it causes problems at runtime.
62+
63+
64+
65+
In Java, generic type information is completely erased at runtime. This process is known as type erasure.
66+
67+
The compiler replaces all type parameters in generic types with their bounds or Object if the type parameters
68+
are unbounded.
69+
70+
This means that the bytecode after compilation contains only ordinary classes, interfaces, and methods.
71+
72+
For example:
73+
74+
```java
75+
List<String> stringList = new ArrayList<>();
76+
List<Integer> intList = new ArrayList<>();
77+
78+
System.out.println(stringList.getClass() == intList.getClass()); // prints true
79+
```
80+
81+
At runtime, both stringList and intList are just List objects, without any information about their generic type.
82+
83+
84+
This approach was chosen to maintain backward compatibility with pre-generics code.
85+
86+
However, it also means that certain operations, like checking if an object is an instance of a specific generic type,
87+
are not possible at runtime.

0 commit comments

Comments
 (0)