Java LocalTime

Java LocalTime

Java LocalTime class is an immutable class that represents time with a default format of hour-minute-second. It inherits Object class and implements the Comparable interface. Method Output LocalTime.of(13, 12, 11) 13:12:11 LocalTime.MIDNIGHT 00:00 LocalTime.NOON 12:00 LocalTime.now() Current time from system clock LocalTime.MAX The maximum supported local time 23:59:59.999999999 LocalTime.MIN The minimum supported local time 00:00 … Read more

Usage of various classes of Date Time API

Usage of various classes of Date Time API

The following example also has an explanation required for understanding the example within it. import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.TimeZone; public class SomeMethodsExamples { /** * Has the methods of the class {@link LocalDateTime} / public static void checkLocalDateTime() { LocalDateTime localDateTime = … Read more

Dates and Time (java.time.*)

Dates And Time in Java

Calculate Difference between 2 LocalDates Use LocalDate and ChronoUnit: LocalDate d1 = LocalDate.of(2017, 5, 1);LocalDate d2 = LocalDate.of(2017, 5, 18); now, since the method between of the ChronoUnit enumerator takes 2 Temporals as parameters so you can pass without a problem the LocalDate instances long days = ChronoUnit.DAYS.between(d1, d2);System.out.println( days ); Related Article: How to … Read more

Primitive Data Types

Primitive Data Types in Java

The 8 primitive data types byte, short, int, long, char, boolean, float, and double are the types that store most raw numerical data in Java programs. The char primitive data types A char can store a single 16-bit Unicode character. A character literal is enclosed in single quotes char myChar = ‘u’;char myChar2 = ‘5’;char … Read more

Date class in Java

Date Class in Java

The Date class of java. util package implements Serializable, Cloneable, and Comparable interface. It provides constructors and methods to deal with date and time with java. Date(): Creates date object representing the current java date and time. Parameter Explanation No parameter Creates a new Date object using the allocation time (to the nearest millisecond) long date Creates a new Date object with the time set to … Read more

Literals in Java

Literals in Java

Java is an Object-Oriented Program. Literals are a representation of a fixed value by source code. They ‘re explicitly interpreted without any computation in the code. Every primitive form variable can be assigned literal. Java literal is a syntactic element (i.e. something you find in the source code of a Java program) that represents a … Read more

String Tokenizer

String Tokenizer in Java

The java.util.StringTokenizer class allows you to break a string into tokens. It is simple way to break string. The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a pertoken basis. StringTokenizer Split by space import java.util.StringTokenizer; public class Simple{ public static void main(String args[]){ StringTokenizer st … Read more

Strings in Java

Strings in Java

Strings (java.lang.String) are pieces of text stored in your program. Strings are not a primitive data type in Java, however, they are very common in Java programs. In Java, Strings are immutable, meaning that they cannot be changed. (Click here for a more thorough explanation of immutability.) Comparing Strings In order to compare Strings for … Read more

Java Data Types

Data Types in Java

There are two types of java data types: Primitive data types: The primitive java data types include boolean, char, byte, short, int, long, float, and double. Non-primitive java data types: The non-primitive java data types include Classes, Interfaces, and Arrays. The Double Primitive Java Data Type A double is a double-precision 64-bit IEEE 754 floating point number. double example = -7162.37; double myDouble = 974.21; … Read more

String pool and heap storage

String pool and heap storage

String is a sequence of characters, for e.g. “Hello” is a string of 5 characters. In java, string is an immutable object which means it is constant and can cannot be changed once it has been created. Finding a String Within Another String To check whether a particular String a is being contained in a … Read more

Java Language – Case insensitive switch

Case Insensitive Switch in Java

Case insensitive switch Version ≥ Java SE 7 switch itself can not be parameterized to be case insensitive, but if absolutely required, can behave insensitively to the input string by using toLowerCase() or toUpperCase: switch (myString.toLowerCase()) { case “case1” : … break; case “case2” : … break;} Beware Locale might affect how changing cases happen! … Read more

How To Split Strings in Java

Split Strings in Java

The string split() method in Java splits a given string around matches of the given regular expression. Example Java StringTokenizer, and String Split. The StringTokenizer class allows us to break a string into tokens in an application. This class is a legacy class retained for purposes of consistency although its use is discouraged in new … Read more

Substrings in Java

Substrings in Java

A segment of the string is called substring. To put it another way, substring is a subset of another string. StartIndex is inclusive and endIndex is exclusive when substring. Substrings String s = “this is an example”; String a = s.substring(11); // a will hold the string starting at character 11 until the end (“example”) … Read more

StringBuffer and StringBuilder Classes in Java

StringBuffer and StringBuilder Classes in Java

Introduction to Java StringBuffer class. In Java StringBuffer class. StringBuffer is a peer string class that provides much of the string functionality. String represents fixed-length, immutable sequences of characters while StringBuffer represents growable, writable sequences of characters. StringBuffer class Key Points: used to created mutable (modifiable) string. Mutable: Which can be changed. is thread-safe i.e. … Read more

Getting Started with Java Language

Java SE Version Code Name End-of-life (free1) Release Date Java SE 10 (Early Access) None future 2018-03-20 Java SE 9 None future 2017-07-27 Java SE 8 Spider future 2014-03-18 Java SE 7 Dolphin 2015-04-14 2011-07-28 Java SE 6 Mustang 2013-04-16 2006-12-23 Java SE 5 Tiger 2009-11-04 2004-10-04 Java SE 1.4 Merlin prior to 2009-11-04 2002-02-06 … Read more

Generics In Java Interview Questions And Answers

Generics In Java Interview Questions

Generics In Java Interview Questions And Answers latest for experienced professionals from Coding Compiler. These Generics In Java interview questions were asked in various interviews conducted by top multinational companies across the globe. We hope that these interview questions on Java Generics will help you in cracking your job interview. All the best and happy … Read more

OOPS Interview Questions ans Answers

Java OOPS Interview Questions

OOPS Interview Questions And Answers for Beginners/Experienced professionals from Codingcompiler. These OOPS interview questions were asked in various interviews conducted by top multinational companies across the globe. We hope that these interview questions on Java OOPS will help you in cracking your next job interview. All the best and happy learning. Oops Interview Questions and … Read more

Java 11 Tutorial For Java Developers

Java Programming Tutorials

Java 11 Tutorial For Java Developers from Coding compilerJava 11 has been available for download since the end of September 2018 and is again a so-called LTS release (long-time support) after Java 8. This is pleasing in that it offers support and updates for a few years, whereas Java 9 and 10 are available through the Oracle’s release policies were only up-to-date for a short period of 6 months and no longer receive any updates. Let’s start learning Java 11.

Read more