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); } } }

8th Apr 2020, 9:02 AM
Ujwal Sambhare
Ujwal Sambhare - avatar
2 Answers
0
What's problem your getting with this code?
8th Apr 2020, 10:20 AM
Jayakrishna 🇼🇳
0
I want to extract data from string according to dataype
9th May 2020, 5:27 AM
Ujwal Sambhare
Ujwal Sambhare - avatar