Venkata Sai has Published 62 Articles

Java program for Multiplication of Array elements.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

15K+ Views

To find the product of elements of an array.create an empty variable. (product)Initialize it with 1.In a loop traverse through each element (or get each element from user) multiply each element to product.Print the product.Example Live Demoimport java.util.Arrays; import java.util.Scanner; public class ProductOfArrayOfElements {    public static void main(String args[]){   ... Read More

Java program to cyclically rotate an array by one.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

2K+ Views

To rotate the contents of an array cyclically −create an empty variable. (temp)save the last element of the array in it.Now, starting from the nth element of the array, replace the current element with the previous element.Store the element in temp in the 1st position.Example Live Demoimport java.util.Arrays; import java.util.Scanner; public ... Read More

Recursive program to find an element in an array linearly.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

781 Views

Following is a Java program to find an element in an array linearly.Example Live Demoimport java.util.Scanner; public class SearchingRecursively {    public static boolean searchArray(int[] myArray, int element, int size){       if (size == 0){          return false;       }       if ... Read More

Program to print Sum Triangle of an array.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

353 Views

To generate a sum triangle of a given arrayGet the elements of the array from the user say, myArray[n].Create a two dimensional array say, result[n][n].Store the contents of the given array in the first row from bottom of the 2D array.result[n][i] = myArray[i].Now, from the second row of the 2D ... Read More

Program for printing array in Pendulum Arrangement.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

501 Views

To arrange elements of the array following pendulum arrangement.Sort the given array, create an empty array to store the result.Store the 0th element in a variable say temp.Store the element at index 1 in the sorted array in (mid+1)st position of the resultant array, and the next element int the ... Read More

Java program to print a given matrix in Spiral Form.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

2K+ Views

Following is a Java program to print the spiral form of a given matrix.Example Live Demopublic class PrintMatrixInSpiralForm {    public static void main(String args[]){       int a[][]={{1,2,3},{4,5,6},{7,8,9}};       int w = 0;       int x = a.length-1;       int y = 0;       int z = a[0].length-1;       while(w

Program to print a matrix in Diagonal Pattern.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

667 Views

Following is the Java program to print diagonal pattern of a given matrix.Example Live Demopublic class DiagonalMatrix {    public static void main(String args[]){       int a[][]={{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};       int rows = a.length;       int columns = a[0].length; ... Read More

Program for converting Alternate characters of a string to Upper Case.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

4K+ Views

You can convert a character to upper case using the toUpperCase() method of the character class.ExampleFollowing program converts alternate characters of a string to Upper Case. Live Demoimport java.util.Scanner; public class UpperCase {    public static void main(String[] args) {       Scanner sc = new Scanner(System.in);       ... Read More

What are Transient variables in Java? Explain.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

269 Views

In Java, serialization is a concept using which we can write the state of an object into a byte stream so that we can transfer it over the network (using technologies like JPA and RMI).While serializing an object of a class, if you want JVM to neglect a particular instance ... Read More

Write a program to convert an array to String in Java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

261 Views

The Arrays class of the java.util package provides a method named toString() this method accepts an array value (of any type) and returns a String.ExampleFollowing Java program accepts various arrays from the user, converts them into String values and prints the results. Live Demoimport java.util.Arrays; import java.util.Scanner; public class ObjectArrayToStringArray {    public ... Read More

Advertisements