
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

8K+ Views
From Java8 java.time package was introduced. This provides classes like LocalDate, LocalTime, LocalDateTime, MonthDay etc. Using classes of this package you can get time and date in a simpler way.Java.time.LocalTime − This class represents a time object without time zone in ISO-8601 calendar system. The now() method of this class obtains the current time from the system clock.Java.time.LocalDateTime − This class represents a date-time object without time zone in ISO-8601 calendar system. The now() method of this class obtains the current date-time from the system clock.ExampleFollowing example retrieves the current time java.time package of Java8.import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; ... Read More

1K+ Views
The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This class represents a date object without time zone in ISO-8601 calendar system. The now() method of this class obtains the current date from the system clock.The of() method of the java.time.LocalDate class accepts three integer parameters representing and year, a month of an year, day of a month and, returns the ... Read More

1K+ Views
The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth, etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This class represents a date object without time zone in ISO-8601 calendar system. The now() method of this class obtains the current date from the system clock.The of() method of java.time.LocalDate class accepts three integer parameters representing and year, a month of an year, day of a month and, returns the instance of ... Read More

26K+ Views
The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This class represents a date object without time zone in ISO-8601 calendar system. The now() method of this class obtains the current date from the system clock.This class also provides various other useful methods among them −The getYear() method returns an integer representing the year filed in the current LocalDate object.The ... Read More

3K+ Views
Prior to Java8 to get current date and time we use to rely on various classes like SimpleDateFormat, Calendar etc.Exampleimport java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class LocalDateJava8 { public static void main(String args[]) { Date date = new Date(); String timeFormatString = "hh:mm:ss a"; DateFormat timeFormat = new SimpleDateFormat(timeFormatString); String currentTime = timeFormat.format(date); System.out.println("Current time: "+currentTime); String dateFormatString = "EEE, MMM d, ''yy"; DateFormat dateFormat = new SimpleDateFormat(dateFormatString); String currentDate = dateFormat.format(date); ... Read More

6K+ Views
An exception is an issue (run time error) occurred during the execution of a program. When an exception occurred the program gets terminated abruptly and, the code past the line that generated the exception never gets executed.There are two types of exceptions in Java.Unchecked Exception − An unchecked exception is the one which occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation.Checked Exception − A checked exception is an exception that occurs at ... Read More

5K+ Views
An exception is an issue (run time error) occurred during the execution of a program. When an exception occurred the program gets terminated abruptly and, the code past the line that generated the exception never gets executed.Try, catch, finally blocksTo handle exceptions Java provides a try-catch block mechanism.A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code.Syntaxtry { // Protected code } catch (ExceptionName e1) { // Catch block }When an exception raised inside a try block, instead of terminating the program JVM stores ... Read More

147 Views
A Run time exception or an unchecked exception is the one which occurs at the time of execution. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation.IndexOutOfBoundsException, ArithmeticException, ArrayStoreException and, ClassCastException are the examples of run time exceptions.ExampleIn following Java program, we have an array with size 5 and we are trying to access the 6th element, this generates ArrayIndexOutOfBoundsException.public class ExceptionExample { public static void main(String[] args) { //Creating an integer array with size 5 int inpuArray[] = ... Read More

4K+ Views
From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions.To read various datatypes from the source using the nextXXX() methods provided by this class namely, nextInt(), nextShort(), nextFloat(), nextLong(), nextBigDecimal(), nextBigInteger(), nextLong(), nextShort(), nextDouble(), nextByte(), nextFloat(), next().Whenever you take inputs from the user using a Scanner class. If the inputs passed doesn’t match the method or an InputMisMatchException is thrown. For example, if you reading an integer data using the nextInt() method and the value ... Read More

561 Views
A daemon thread is a low-priority thread in java which runs in the background and mostly created by JVM for performing background tasks like Garbage Collection(GC). If no user thread is running then JVM can exit even if daemon threads are running. The only purpose of a daemon thread is to serve user threads. The isDaemon() method can be used to determine the thread is daemon thread or not. Syntax Public boolean isDaemon() Example class SampleThread implements Runnable { public void run() { if(Thread.currentThread().isDaemon()) System.out.println(Thread.currentThread().getName()+" is daemon thread"); ... Read More