List of usage examples for java.lang Integer parseInt
public static int parseInt(String s) throws NumberFormatException
From source file:MainClass.java
public static void main(String args[]) { int i = Integer.parseInt("3"); int j = Integer.parseInt("5"); int sum = i + j; System.out.print("Sum is " + sum); }
From source file:Main.java
public static void main(String[] args) { ToIntFunction<String> i = (x) -> Integer.parseInt(x); System.out.println(i.applyAsInt("2")); }
From source file:Main.java
public static void main(String[] args) { ToIntBiFunction<String, String> i = (x, y) -> Integer.parseInt(x) + Integer.parseInt(x); System.out.println(i.applyAsInt("2", "3")); }
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "25"; int i = Integer.valueOf(str).intValue(); // or/* w w w. java 2 s .co m*/ i = Integer.parseInt(str); }
From source file:MainClass.java
public static void main(String[] args) { String s;/*from ww w .j a v a 2 s .co m*/ s = JOptionPane.showInputDialog("Enter an integer:"); int x = Integer.parseInt(s); System.out.println("You entered " + x + "."); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String age = "1"; String height = "1.5"; String weight = "5.9"; int theAge = Integer.parseInt(age); float theHeight = Float.parseFloat(height); double theWeight = Double.parseDouble(weight); System.out.println("Age: " + theAge); System.out.println("Height: " + theHeight); System.out.println("Weight: " + theWeight); }
From source file:Main.java
public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter the x coordinate of the circle"); int xc = Integer.parseInt(input); System.out.println(xc);//from w w w .j a v a 2 s . c om }
From source file:DatagramReceiver.java
public static void main(String args[]) throws Exception { int port = Integer.parseInt(args[0]); DatagramSocket ds = new DatagramSocket(port); byte buffer[] = new byte[BUFSIZE]; while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); ds.receive(dp);/* w w w .java 2 s.c o m*/ System.out.println(new String(dp.getData())); } }
From source file:Collector.java
public static void main(String args[]) throws Exception { int port = Integer.parseInt(args[0]); DatagramSocket ds = new DatagramSocket(port); while (true) { byte buffer[] = new byte[BUFSIZE]; DatagramPacket dp = new DatagramPacket(buffer, buffer.length); ds.receive(dp);/*from www . j a v a 2 s .co m*/ System.out.println(new String(dp.getData())); } }
From source file:SocketDemo.java
public static void main(String args[]) throws Exception { String server = args[0];//from w ww.ja va2s . co m int port = Integer.parseInt(args[1]); Socket s = new Socket(server, port); InputStream is = s.getInputStream(); DataInputStream dis = new DataInputStream(is); System.out.println(dis.readInt()); s.close(); }