Samual Sam has Published 2314 Articles

Static Keyword in C++

Samual Sam

Samual Sam

Updated on 10-Dec-2024 18:20:10

15K+ Views

When a static keyword is used, variables, data members, and functions can not be modified again. It is allocated for the lifetime of the program. Static functions can be called directly by using a class name. Key Points of Static Variables Static variables are variables that are defined using static ... Read More

Java program to print the diamond shape

Samual Sam

Samual Sam

Updated on 23-Nov-2024 03:55:38

298 Views

In this article, we will learn how to print a diamond shape pattern using nested loops in Java. This helps in understanding loops and conditional structures in Java programming.A nested loop refers to a loop placed within another loop. This structure is often called "loops within loops" because the inner ... Read More

Java Program to check whether a file exists or not

Samual Sam

Samual Sam

Updated on 23-Nov-2024 03:51:25

241 Views

In this article, we will learn how to check whether a file exists using Java. The program demonstrates the use of the exists() method from the java.io.File class to perform this check. Java.io.File.exists() MethodThe java.io.File.exists() method returns true if the file path exists, otherwise it returns false. Parameters: This method ... Read More

Java Program to Match Zip Codes

Samual Sam

Samual Sam

Updated on 23-Nov-2024 03:49:21

373 Views

In this article, we will learn how to validate U.S. zip codes using a regular expression in Java. The program checks if a given string is a valid U.S. zip code, either in the standard five-digit format or the extended nine-digit format.Zip Code Format In the U.S., zip codes are ... Read More

Java program to get display name for day of week in different locale

Samual Sam

Samual Sam

Updated on 23-Nov-2024 03:47:56

330 Views

In this article, we will learn how to get the display name for a day of the week in different locales using Java. The DayOfWeek class in Java provides methods to work with days of the week, and with the help of getDisplayName(), you can retrieve the name of a ... Read More

Java program to subtract hours from current time using Calendar.add() method

Samual Sam

Samual Sam

Updated on 20-Nov-2024 22:39:59

743 Views

In this article, we use the Calendar class in Java to work with dates and times. First, it retrieves the current date and time and displays it. Then, the program increments the current time by 5 hours using the add() method and displays the updated date and time. This is ... Read More

Java program to print a Fibonacci series

Samual Sam

Samual Sam

Updated on 18-Nov-2024 22:31:46

3K+ Views

The Fibonacci Series generates subsequent numbers by adding two previous numbers. The Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken as 0, 1, or 1, 1 respectively. Fn = Fn-1 + Fn-2 Problem Statement Write a program in ... Read More

Java program to check if a particular element exists in HashSet

Samual Sam

Samual Sam

Updated on 15-Nov-2024 18:48:37

1K+ Views

In this article, we will learn how to use the contains() method in Java's HashSet class to check whether specific elements are present in a set. We'll create a HashSet, add some elements to it, and verify the existence of given elements using the contains() method. Problem Statement Write a ... Read More

Java program to convert HashMap to TreeMap

Samual Sam

Samual Sam

Updated on 15-Nov-2024 18:43:54

614 Views

In this article, we will convert a HashMap to a TreeMap in Java. A HashMap is used for storing data as key-value pairs, but it doesn’t keep the keys in any particular order. A TreeMap sorts the keys in ascending order. By converting a HashMap to a TreeMap, we can ... Read More

Java Program to check whether the entered value is ASCII 7 bit alphabetic

Samual Sam

Samual Sam

Updated on 15-Nov-2024 18:42:19

163 Views

In this article, we will discover how we can check whether a value entered is an ASCII 7-bit alphabetic character in Java. This process involves whether a character belongs to the ranges 'a' to 'z' or 'A' to 'Z' in the ASCII table. The character can be checked with some ... Read More

Advertisements