0
Extract data from string I want separate output int, float, string
/* I want to extract datatypes from string */ import java.util.Scanner; public class Dcoder{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); String s ; System.out.println("Enter the string"); s= sc.next(); try{ System.out.println(s); int i=Integer.parseInt(s); System.out.println(s); System.out.println(i); long l=Long.parseLong(s); System.out.println(l); float f= Float.parseFloat(s); System.out.println(f); } catch(Exception e){ System.out.println(e); } } }
2 Answers
0
What's problem your getting with this code?
0
I want to extract data from string according to dataype