Java Tutorials
JasperReports Tutorial: What is, How to Install, Report Example
What is JasperReports for Java? JasperReports is an open-source reporting tool for Java that is...
In this tutorial, we will study programs to
There are multiple ways to convert a Char to String in Java. In fact, String is made of Character array in Java. Char is 16 bit or 2 bytes unsigned data type.
We can convert String to Character using 2 methods -
public class CharToString_toString { public static void main(String[] args) { //input character variable char myChar = 'g'; //Using toString() method //toString method take character parameter and convert string. String myStr = Character.toString(myChar); //print string value System.out.println("String is: " + myStr); } }
String is: g
public class CharToString_valueOf { public static void main(String[] args) { char myChar = 'g'; //valueOf method take character parameter and convert string. String myStr = String.valueOf(myChar); ////print string value System.out.println("String is: " + myStr); } }
String is: g
//Convert String to Character using string method package com.guru99; public class StringToChar { public static void main(String[] args) { //input String String myStr = "Guru99"; //find string length using length method. int stringLength =myStr.length(); //for loop start 0 to total length for(int i=0; i < stringLength;i++) { //chatAt method find Position and convert to character. char myChar = myStr.charAt(i); //print string to character System.out.println("Character at "+i+" Position: "+myChar); } } }
Character at 0 Position: G Character at 1 Position: u Character at 2 Position: r Character at 3 Position: u Character at 4 Position: 9 Character at 5 Position: 9
What is JasperReports for Java? JasperReports is an open-source reporting tool for Java that is...
Follow the simple steps below to compile and execute any JAVA program online using your favourite...
What is OOPS? Object-Oriented Programming System (OOPs) is a programming concept that works on the...
What is a Prime Number? A prime number is a number that is only divisible by 1 or itself. For...
We all use switches regularly in our lives. Yes, I am talking about electrical switches we use for our...
Java String contains() method The Java String contains() method is used to check whether the...