Skip to content

A brief overview of common use Java methods, boilerplate code, and more.

Notifications You must be signed in to change notification settings

chaseofthejungle/java-quick-reference-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

Java Quick Reference Guide

Description/Overview: A lookup 'sheet' of common use Java methods, boilerplate code, and more. For more advanced data structures guidance/solutions and clean coding advice, see the Supplemental Resources section.

Table of Contents

  1. Syntax and Data Types
  2. Mathematical and Logical Operators
  3. Control Flow/Decision Structures
  4. Arrays
  5. Strings
  6. Methods
  7. Object-Oriented Programming (OOP) Principles
  8. Exception Handling
  9. Java Collections Framework (JCF)
  10. Generics
  11. File Input/Output (I/O)
  12. Multithreading
  13. Lambda Expressions and Functional Interfaces
  14. Stream API
  15. Time API
  16. Networking
  17. Reflection
  18. Annotations
  19. Java Database Connectivity (JDBC)
  20. Supplemental Resources






  • Method declaration: public int addVals(int a, int b) { return a + b; }
  • Method overload (if added to a class with the above method): public int addVals(int a, int b, int c) { return a + b + c; }




  • Generic class: public class ClassName<T> { }
  • Generic method: public <T> void methodName(T parameter) { }
  • Bounded type parameter (with generic method): public <T extends Number> void methodName(T parameter) { }
  • Wildcard: public void methodName(List<?> list) { }





Retrieving present values...

  • Present date: LocalDate date = LocalDate.now();
  • Present time: LocalTime time = LocalTime.now();
  • Present date and time: LocalDateTime dateTime = LocalDateTime.now();
  • Present day (of week): DayOfWeek dayOfWeek = date.getDayOfWeek();

Retrieving more specific values...

  • A specific date: LocalDate date = LocalDate.of(2024, 10, 6);
  • Period between dates: Period period = Period.between(date1, date2);
  • Duration between times: Duration duration = Duration.between(time1, time2);

Performing mathematical operations...

  • Adding days to a date: LocalDate future = date.plusDays(5);
  • Adding years to a date: LocalDate future = date.plusYears(4);
  • Subtracting months from a date: LocalDate past = date.minusMonths(2);

Parsing, formatting, and conditional logic...

  • Parsing a date (from String data): LocalDate date = LocalDate.parse("2020-02-09");
  • Formatting a date (from String data): String formatted = date.format(DateTimeFormatter.ISO_DATE);
  • Evaluate if a year is a leap year: boolean isLeapYear = date.isLeapYear();





Java Clean Coding Guide
Java Data Structure Leetcode Interview Questions


About

A brief overview of common use Java methods, boilerplate code, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published