Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
jb15.0
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.util.function.IntPredicate; import java.lang.*; import java.math.*; class Rextester { public static void main(String args[]) { System.out.println("Hello, World!"); MyTest t = n -> n >= 10? (n<=20? true: false) : false; System.out.println(t.testing(5)); System.out.println(t.testing(10)); System.out.println(t.testing(15)); System.out.println(t.testing(20)); System.out.println(t.testing(25)); System.out.println("---"); NumericFunc factorial = n -> { int result = 1; for(int i = n; i>1; i--) result *= i; return result; }; System.out.println(factorial.func(1)); System.out.println(factorial.func(2)); System.out.println(factorial.func(3)); System.out.println(factorial.func(4)); System.out.println(factorial.func(5)); System.out.println("---"); NumericFuncT<Double> factorialT = n -> { Double result = 1.0; for(int i = n.intValue(); i>1; i--) result *= i; return result; }; System.out.println(factorialT.func(6.0)); System.out.println("---"); MyIntFubric mif = MyIntNum::new; MyIntNum min = mif.create(10); IntPredicate ip = min::hasCommonFactor; System.out.println(ip.test(4)); System.out.println(ip.test(3)); System.out.println(ip.test(5)); System.out.println(ip.test(8)); System.out.println("---"); } } interface MyIntFubric{ MyIntNum create(int n); } class MyIntNum{ int _n; MyIntNum(int n){ _n = n; } public boolean hasCommonFactor(int m){ boolean result = false; for(int i=2; i<=(Math.min(_n, m))/2; i++){ if((_n%i == 0) && (m%i == 0)){ result = true; break; } } return result; } } interface MyTest{ boolean testing(int n); } interface NumericFunc{ int func(int n); } interface NumericFuncT<T>{ T func(T n); }
[
+
]
Show input
Compilation time: 0.73 sec, absolute running time: 0.23 sec, cpu time: 0.27 sec, memory peak: 25 Mb, absolute service time: 0,97 sec
edit mode
|
history
|
discussion
Hello, World! false true true true false --- 1 2 6 24 120 --- 720.0 --- true false false true ---