List of usage examples for java.lang Long parseLong
public static long parseLong(String s) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { System.out.println(Long.parseLong("12345")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { long l = Long.parseLong("123"); System.out.println(l);// w w w . ja v a2 s. com }
From source file:Main.java
public static void main(String[] args) { String str = new String("10"); long l = Long.parseLong(str); System.out.println(l);//from www .j a va2 s .com }
From source file:Main.java
public static void main(String[] args) { ToLongFunction<String> i = (x) -> Long.parseLong(x); System.out.println(i.applyAsLong("2")); }
From source file:Main.java
public static void main(String[] args) { ToLongBiFunction<String, String> i = (x, y) -> Long.parseLong(x) + Long.parseLong(y); System.out.println(i.applyAsLong("2", "2")); }
From source file:Main.java
public static void main(String[] args) throws Exception { String str = "0.5"; long l = Long.valueOf(str).longValue(); // or// w w w . ja v a2 s .com Long L = Long.parseLong(str); }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1", "2", "3", "4", "5"); stringList.stream().mapToLong(n -> Long.parseLong(n)).filter(n -> n % 2 == 0).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { Stream<String> s = Stream.of("1", "2", "3"); double o = s.collect(Collectors.averagingLong(n -> Long.parseLong(n))); System.out.println(o);//w ww .j av a2 s . c o m }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1.2", "2.2", "3", "4", "5"); stringList.stream().flatMapToLong(n -> LongStream.of(Long.parseLong(n))).forEach(System.out::println); }
From source file:Primes.java
public static void main(String[] args) { long[] prime = new long[MAX]; long stop = DEFAULT_STOP; if (args.length == 1) { stop = Long.parseLong(args[0]); }//from w ww . j av a 2 s .c om prime[1] = FP; // P1 (ignore prime[0]) long n = FP + 1; // odd candidates int j = 1; // numberFound boolean isPrime = true; // for 3 do { if (isPrime) { if (j == MAX - 1) { // Grow array dynamically if needed long[] np = new long[MAX * 2]; System.arraycopy(prime, 0, np, 0, MAX); MAX *= 2; prime = np; } prime[++j] = n; // P2 isPrime = false; } n += 2; // P4 for (int k = 2; k <= j && k < MAX; k++) { // P5, P6, P8 long q = n / prime[k]; long r = n % prime[k]; if (r == 0) { break; } if (q <= prime[k]) { // P7 isPrime = true; break; } } } while (n < stop); // P3 for (int i = 1; i <= j; i++) System.out.println(prime[i]); }