Arrays:: DS Basics
Arrays:: DS Basics
Arrays:
Declare an array of size 10.
Int[] seq = new int[10];
Switch Statement
class HelloWorld {
public static void main(String args[]) {
int i = 0;
switch(i){
case 0:
System.out.println("int = 0");
break;
default:
System.out.println("int != 0");
}
}
}
How To Convert Char To String In Java?
Approach #1
Approach #2
Here is another way, which is equivalent to the one above. You can create an instance of the
class Character using its constructor. This is called boxing. Boxing means wrapping a primitive
type with its equivalent object type.
Once you wrap the character, you can call the toString() method to get the String. See below
how this works:
Approach #3
The String class also offer a way to convert char to string. You can use the static method
valueOf() passing as a parameter(or argument), the character you want to convert. As a
result, you will get exactly the same character saved in a string variable. See below how this
will work:
import java.util.Arrays;
import java.util.List;
public class Sample {