Program to print the elements of an array17 Mar 2025 | 1 min read This is a simple program to create an array and then to print it's all elements. Now, just know about arrays. Arrays are the special variables that store multiple values under the same name in the contiguous memory allocation. Elements of the array can be accessed through their indexes. ![]() Here, 1, 2, 3, 4 and 5 represent the elements of the array. These elements can be accessed through their corresponding indexes, 1.e., 0, 1, 2, 3 and 4. Algorithm
Program:Output: Elements of given array: 1 2 3 4 5 Next TopicJava Programs |
In this program, all the subsets of the string need to be printed. The subset of a string is the character or the group of characters that are present inside the string. All the possible subsets for a string will be n(n+1)/2. For example, all possible subsets...
2 min read
In this section, we will discuss what is Armstrong number and also create Java programs to check if the given number is an Armstrong number or not. The Armstrong number program frequently asked in Java coding interviews and academics. Armstrong Number An Armstrong number is a positive...
5 min read
Java Convert Date to Timestamp We can convert Date to Timestamp in java using constructor of java.sql.Timestamp class. The constructor of Timestamp class receives long value as an argument. So you need to convert date into long value using getTime() method of java.util.Date class. You can also format the...
2 min read
? In Java, the sort() method is a static and overloaded method defined in the java.util.Arrays class. It is used to sort arrays values of different types. The order may be in ascending or descending order. The numerical and lexicographical (alphabetical) order is widely used. The sort()...
11 min read
Java Program to add two matrices We can add two matrices in java using binary + operator. A matrix is also known as array of arrays. We can add, subtract and multiply matrices. To subtract two matrices, use - operator. Let's see a simple example to add two...
1 min read
Java Convert char to String We can convert char to String in java using String.valueOf(char) method of String class and Character.toString(char) method of Character class. Java char to String Example: String.valueOf() method Let's see the simple code to convert char to String in java using String.valueOf() method. char c='S'; String s=String.valueOf(c); Let's...
1 min read
In this program, we will create a singly linked list and add a new node at the end of the list. To accomplish this task, add a new node after the tail of the list such that tail's will point to the newly added...
4 min read
In this program, we will create a doubly linked list and delete a node from the end of the list. If the list is empty, print the message "List is empty". If the list is not empty, tail's ious node will become the new tail...
6 min read
In this program, we need to multiply two matrices and print the resulting matrix. Product of two matrices The product of two matrices can be computed by multiplying elements of the first row of the first matrix with the first column of the second matrix then, add...
6 min read
Write a ? File: RemoveChar .java public class ReverseStringPreserveSpace { static void reverseString(String input) { char[] inputArray = input.toCharArray(); char[] result = new char[inputArray.length]; for (int i = 0; i < inputArray.length; i++) { if (inputArray[i] == ' ') { result[i] = ' '; } } int j = result.length - 1; for...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India