Convert Data Type in Java

Parsing value from a String

public class ConvertDataType {
    public static void main(String[] args) {
        
        String num = "1.4324";
        double realNum = Double.parseDouble(num);
        System.out.println(++realNum);
    }
}
2.4324
  • A String in Java is a nonprimitive data type, because it refers to an object.

Leave a Reply

Your email address will not be published.

ANOTE.DEV