Skip to main content

27 posts tagged with "Java"

Java Programming Language and the JDK

View All Tags

How to Put a Java Class in a Package

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Packages group related Java classes and give them unique full names, such as com.example.Main. A class joins a package with one package line at the top of its file, and its file sits in folders that match the package's name.

How to Chain Method Calls in Java

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

When a method returns an object, you can call the next method on it right away: text.strip().toLowerCase(). That's method chaining. In Java it comes in two flavours: methods that return a new value, like String's, and builders whose methods return the builder itself.

How to Catch a Specific Exception in Java

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

When something goes wrong in Java, the code throws an exception, and the program stops unless a catch handles it. A catch that names one exception type handles the failure you expected and lets every other one through, so real bugs still show up.