Skip to content

chaseofthejungle/java-quick-reference-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 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

(TODO)


(TODO)


(TODO)


(TODO)


(TODO)


  • 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; }

(TODO)


(TODO)


(TODO)


  • 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) { }

(TODO)


(TODO)


(TODO)


(TODO)


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();

(TODO)


(TODO)


(TODO)


(TODO)



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