![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 9326 Articles for Object Oriented Programming
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
856 Views
Each word in a sentence can be reversed and the sentence displayed with the words in the same order as before. An example of this is given as follows −Original sentence = an apple is red Modified sentence = na elppa si derA program that demonstrates this is given as follows.Example Live Demopublic class Example { public static void main(String[] args) { String str = "the sky is blue"; System.out.println("The original string is: " + str); String strWords[] = str.split("\s"); String rev = ""; for(String sw : strWords) { StringBuilder sb = new StringBuilder(sw); sb.reverse(); rev += sb.toString() + " "; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the seconds using the calendar.add() method and Calendar.SECOND constant.calendar.add(Calendar.SECOND, 15);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Add 15 seconds to current date calendar.add(Calendar.SECOND, 15); System.out.println("Updated Date = " + calendar.getTime()); } ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us decrement the months using the calendar.add() method and Calendar.MONTH constant. Set a negative value since we are decrementing.calendar.add(Calendar.MONTH, -10);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Subtract 8 months from current date calendar.add(Calendar.MONTH, -8); System.out.println("Updated Date = " + calendar.getTime()); } }OutputCurrent Date = Thu Nov 22 16:37:42 UTC 2018 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
4K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the months using the calendar.add() method and Calendar.MONTH constant.calendar.add(Calendar.MONTH, 8);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Add 8 months to current date calendar.add(Calendar.MONTH, 8); System.out.println("Updated Date = " + calendar.getTime()); } ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us decrement the minutes using the calendar.add() method and Calendar.MINUTE constant. Set a negative value since you want to decrease the minutes.calendar.add(Calendar.MINUTE, -15);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Subtract 15 minutes from current date calendar.add(Calendar.MINUTE, -15); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the minutes using the calendar.add() method and Calendar.HOUR_OF_DAY constant.calendar.add(Calendar.MINUTE, 10);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Add 10 minutes to current date calendar.add(Calendar.MINUTE, 10); System.out.println("Updated Date = " + calendar.getTime()); } ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
448 Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the hours using the calendar.add() method and Calendar.HOUR_OF_DAY constant. Set a negative value since you want to decrease the hours.calendar.add(Calendar.HOUR_OF_DAY, +5);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Incrementing hours by 5 calendar.add(Calendar.HOUR_OF_DAY, +5); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the hours using the calendar.add() method and Calendar.HOUR_OF_DAY constant.calendar.add(Calendar.HOUR_OF_DAY, +5);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Incrementing hours by 5 calendar.add(Calendar.HOUR_OF_DAY, +5); System.out.println("Updated Date = " + calendar.getTime()); } }OutputCurrent Date ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime());Now, let us subtract the days using the add() method and Calendar.DATE constant. Set a negative value here since we are decrementing.calendar.add(Calendar.DATE, -2);Example Live Demoimport java.util.Calendar; public class Demo { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime()); // Decrementing days by 2 calendar.add(Calendar.DATE, -2); System.out.println("Updated Date = " + ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
An array can be reversed in groups of given size by reversing the subarrays of the required size. An example of this is given as follows.Array = 1 2 3 4 5 6 7 8 9 10 Group size = 3 Modified array = 3 2 1 6 5 4 9 8 7 10A program that demonstrates this is given as follows.Example Live Demopublic class Example { public static void main(String[] args) { int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9 ,10}; int size = 4; int ... Read More