Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Java Articles
Page 166 of 450
Java program to subtract 40 days from the calendar
In this article, we will learn to subtract 40 days from the calendar in Java. Working with dates is a frequent need in programming, and there are multiple methods of doing it in Java. One of the simplest approaches is to use the Calendar class to remove days from a date. Different Approaches The following are the two to subtract 40 days from the calendar in Java − Using the Calendar Class Using the LocalDate Class Using the Calendar Class The first approach utilizes the Calendar class, which is part ...
Read MoreJava program to map string list to lowercase and sort
In this article, we will learn to map a String list to lowercase and sort in Java. We need to manipulate the elements of a list, such as converting all strings to lowercase and sorting them. This is particularly useful when dealing with user input, file processing, or data normalization. Problem Statement Given a list of strings, we want to convert all strings to lowercase and sort the list in reverse alphabetical order.For Example: Input ["Apple", "banana", "Cherry", "date"] Output ["date", "cherry", "banana", "apple"] Using Streams API The Streams API provides a useful and functional approach to processing ...
Read MoreJava program to display date and time information in uppercase
In this article, we will learn to display the date and time in uppercase using Java. Working with date and time in Java is a common requirement in various applications, logging, scheduling, or data processing. Different Approaches The following are the two different approaches to display the date and time in uppercase using Java − Using Formatter and Calendar Using DateTimeFormatter Using Formatter and Calendar The Formatter class in Java allows us to format date and time using the %Tc specifier. We can then convert the output to uppercase using ...
Read MoreIs string a primitive data type or an object in Java?
In Java there are various data types present, the String type often leads to confusion regarding whether it is a primitive data type or an object(non-primitive data type ). Primitive Data Types in Java Primitive data types are the most basic data types the Java language provides. Primitive data types are not objects and do not have methods or properties. Eg: int (32-bit), float(32-bit), double(64-bit ), etc. What is String in Java? A string is not a primitive data type. Java.lang package provides the String class therefore, it is an object type. The String class provides methods to manipulate and operate ...
Read MoreDuck Numbers in Java
A duck number is a positive number that contains a zero in it, but the first digit of the number cannot be a zero. For example, 10305, 20050, and 603 are duck numbers, while 0349 and 2987 are not duck numbers, as 0349 starts with 0 and 2987 does not contain 0 in it. The following are the approaches to find the duck number in Java − Using a while Loop Using the contains() operator Let’s understand each approach in detail. Finding Duck Number Using a While Loop In this approach, we take a number as input and ...
Read MoreATM Program JAVA
In this article, we will learn how to build a simple ATM machine program in Java. This program lets users choose from the options displayed on the screen. Before choosing the options, the user has to enter their ATM PIN for verification. The default PIN will be '1234', which can be changed if needed. If the PIN is wrong, you will be exited from the program. If the PIN is correct, then the user can choose from the following − Java ATM Program Operations The following are the operations that you can perform with the program − ...
Read MoreWhat is memory-mapped file in Java?
Memory mapping is a technique in Java that gives direct access to files through memory (RAM). A memory-mapped file connects disk content straight to RAM, which lets Java applications handle files as memory segments. This makes files to be treated as a large array and is much faster than regular file operations like read() or write(). This requires fewer system calls and makes file operations faster even for very large files. The java.nio package helps us to implement memory-mapped file operations. This package contains the MappedByteBuffer class, which enables efficient file reading and writing from memory. Use cases of memory-mapped ...
Read MoreXylem and Phloem Number in Java
A number is a Xylem number if the sum of extreme digits (first and last) equals the sum of its mean digits (all digits except first and last). If the sum of the extreme digits does not match the sum of the mean digits, then it is a Phloem number. We can understand it with the help of examples − Example 1 Take the number 12326: Sum of its extremes is 1+6=7. The sum of its mean digits is 2+3+2=7. Sum of extremes = Sum of mean digits, so it is a xylem number. Example 2 The number is ...
Read MorePrint the season name of the year based on the month number in java
In this article, we will explore different methods to find the season name from the month number in Java. When the user inputs the month number, the output should be the season by the name associated with the month. If the user enters 1 as the month number, the month is January, so the output will be Winter. Given below is the season classification by months Winter: December (12), January (1), February (2) Spring: March (3), April (4), May (5) Summer: June (6), July (7), August (8) Autumn: September (9), October (10), November (11) We can achieve this using several ...
Read MoreGiuga Number in Java
In this article, we will learn about Giuga Numbers and how to write a code to check if a number is a Giuga Number or not in Java. A Giuga number is a composite number N such that for each prime factor p of N, (N/p)-1 is divisible by p. The first Giuga numbers are 30, 858, 1722, 66198, 2214408306, 24423128562, and 432749205173838. Example Lets take N=30. 30 is a composite number, and its prime factors are 2, 3, and 5. ● For p=2: (N/p)-1 to be divisible by p. N is 30, and p here is 2. (30/2)-1=14, ...
Read More