Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 87 of 151

Make a left-aligned with Bootstrap

Samual Sam
Samual Sam
Updated on 11-Mar-2026 3K+ Views

Use the .form-inline class in Bootstrap to make a left aligned.You can try to run the following code to implement .form-inline classExample           Bootstrap Example                                                       Name                                             Name                                Submit          

Read More

Add style to images with Bootstrap

Samual Sam
Samual Sam
Updated on 11-Mar-2026 785 Views

The following classes are provided by Bootstrap to add style to images: .img-rounded − adds border-radius:6px to give the image rounded corners. .img-circle − makes the entire image round by adding border-radius:500px. .img-thumbnail − adds a bit of padding and a gray borderYou can try to run the following code to add style to imagesExample           Bootstrap Images                                 Styling images with Bootstrap                      

Read More

How to execute a static block without main method in Java?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

VM first looks for the main method (at least the latest versions) and then, starts executing the program including static block. Therefore, you cannot execute a static block without main method. Example public class Sample { static { System.out.println("Hello how are you"); } } Since the above program doesn’t have a main method, If you compile and execute it you will get an error message. C:\Sample>javac StaticBlockExample.java C:\Sample>java StaticBlockExample Error: Main method not found in class StaticBlockExample, please define the main method as: public static ...

Read More

How to switch data from an array to array list in java?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 352 Views

The Arrays class of the java.util package provides you a method named asList(). This method accepts an array (of objects) and converts them into a list and returns it.Exampleimport java.util.Arrays; import java.util.List; public class ArrayToList {    public static void main(String args[]) {       Integer[] myArray = {23, 93, 56, 92, 39};       List list = Arrays.asList(myArray);       System.out.println(list);    } }Output[23, 93, 56, 92, 39]

Read More

Concatenate string to an int value in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 30K+ Views

To concatenate a string to an int value, use the concatenation operator.Here is our int.int val = 3;Now, to concatenate a string, you need to declare a string and use the + operator.String str = "Demo" + val;Let us now see another example.Exampleimport java.util.Random; public class Demo {    public static void main( String args[] ) {       int val = 3;       String str = "" + val;       System.out.println(str + " = Rank ");    } }Output3 = Rank

Read More

Array Copy in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 30K+ Views

Array in Java can be copied to another array using the following ways.Using variable assignment. This method has side effects as changes to the element of an array reflects on both the places. To prevent this side effect following are the better ways to copy the array elements.Create a new array of the same length and copy each element.Use the clone method of the array. Clone methods create a new array of the same size.Use System.arraycopy() method.  The arraycopy() can be used to copy a subset of an array.ExampleCreate a java class named Tester.Tester.javapublic class Tester {    public static ...

Read More

How to find Min/Max numbers in a java array?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 32K+ Views

You can find the minimum and maximum values of an array using for loops −Examplepublic class MinAndMax {    public int max(int [] array) {       int max = 0;             for(int i=0; imax) {             max = array[i];          }       }       return max;    }    public int min(int [] array) {       int min = array[0];             for(int i=0; i

Read More

How to convert string to array of integers in java?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 44K+ Views

You can convert a String to integer using the parseInt() method of the Integer class. To convert a string array to an integer array, convert each element of it to integer and populate the integer array with them.Exampleimport java.util.Arrays; public class StringToIntegerArray { public static void main(String args[]) { String [] str = {"123", "345", "437", "894"}; int size = str.length; int [] arr = new int [size]; for(int i=0; i

Read More

How to pass Arrays to Methods in Java?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 66K+ Views

You can pass arrays to a method just like normal variables. When we pass an array to a method as an argument, actually the address of the array in the memory is passed (reference). Therefore, any changes to this array in the method will affect the array.Suppose we have two methods min() and max() which accepts an array and these methods calculates the minimum and maximum values of the given array respectively:Exampleimport java.util.Scanner; public class ArraysToMethod {    public int max(int [] array) {       int max = 0;       for(int i=0; imax) {   ...

Read More

Java NumberFormat.getPercentageInstance() Method

Samual Sam
Samual Sam
Updated on 28-Jan-2025 762 Views

In this article, we will learn the NumberFormat.getPercentageInstance() method. Java provides powerful tools for formatting numbers, currencies, and percentages through the java.text.NumberFormatclass. One of the most useful methods in this class is the getPercentageInstance() method. NumberFormat.getPercentageInstance() method The NumberFormat.getPercentageInstance() method is a static method that returns a NumberFormat instance configured to format numbers as percentages. This method can be used with or without a Locale parameter.  Syntax − public static NumberFormat getPercentageInstance()public static NumberFormat getPercentageInstance(Locale locale) Without Locale: If no locale is specified, the method uses the default locale of the JVM. ...

Read More
Showing 861–870 of 1,507 articles
« Prev 1 85 86 87 88 89 151 Next »
Advertisements