Master networking with sockets, Java modules system, and modern features like records and sealed classes.
Learn advanced networking, modular architecture, and Java 14+ features.
URL url = new URL("http://...");HttpURLConnection conn = (HttpURLConnection) url.openConnection();ServerSocket server = new ServerSocket(port);Socket client = server.accept();Socket socket = new Socket(host, port);--- URL Connection Demo ---
Connecting to: https://api.example.com
Response Code: 200
Content Type: application/json
--- Socket Concepts ---
Server would listen on port: 8080
Client would connect to: localhost:8080
--- InetAddress Demo ---
Localhost: 127.0.0.1
Hostname: localhost
new URL("http://example.com")(HttpURLConnection) url.openConnection()new ServerSocket(port)new Socket(host, port)InetAddress.getLocalHost()Review feedback below
module com.myapp { }exports com.myapp.api;exports com.myapp.util to com.other;requires java.sql;requires transitive java.logging;provides MyService with MyServiceImpl;uses MyService;--- Java Module System Demo ---
Module Declaration Example:
module com.myapp {
requires java.base;
requires java.sql;
requires transitive java.logging;
exports com.myapp.api;
exports com.myapp.util to com.other;
opens com.myapp.internal to com.framework;
provides com.myapp.spi.Service with com.myapp.impl.ServiceImpl;
uses com.myapp.spi.Plugin;
}
Current Module: unnamed module
module com.myapp { }requires java.sql;exports com.myapp.api;opens com.myapp to framework;provides X with Y;Review feedback below
record Person(String name, int age) { }sealed class Shape permits Circle, Rectangle { }final, sealed, or non-sealed--- Records Demo ---
Person: Person[name=Alice, age=30]
Name: Alice, Age: 30
Equals: true
HashCode match: true
--- Sealed Classes Demo ---
Circle area: 78.54
Rectangle area: 24.00
Triangle area: 6.00
--- Pattern Matching ---
Processing Circle with radius 5.0
Processing Rectangle 4.0 x 6.0
Processing Triangle with base 3.0
record Point(int x, int y) { }point.x() not point.getX()sealed class X permits A, B { }final class A extends X { }if (obj instanceof Type t) { use t }Review feedback below