JAVA SP T


Lets dive into snapshot of my programs!💻

11.How to convert String to char.

💡Code:

 public class StringToCharConversion7078 {
              public static void main(String[] args) {
                  // Example string
                  String inputString = "Hello";
          
                  // Convert the string to a char array
                  char[] charArray = inputString.toCharArray();
          
                  // Print each character
                  for (char character : charArray) {
                      System.out.println("Converted char: " + character);
                  }
              }
          }
           

📸Output :

output