+ 1

Can i write check prime number code in one line using java language.

19th Sep 2017, 1:49 PM
Rushikesh Chaudhari
Rushikesh Chaudhari - avatar
5 Respostas
+ 8
yes😂
19th Sep 2017, 2:00 PM
Changed
Changed - avatar
+ 6
Technically, you can write your entire program on one line.
19th Sep 2017, 1:52 PM
AgentSmith
+ 4
*Less lines of code does not mean the algorithm is faster.* You can make it look like one line of code. Create a separate file for a class. Then create a public static boolean method called isPrime(int x). Which finds out if the number is prime. Then, you can go to your main file and simply write: myClass.isPrime(userInput); This is what things like Math.pow() or Collections.sort() do. It isn't really one line of code, only appears to be to make the programmer have to look at less. (Or you can do what @nektos said and just don't hit 'enter' in your program 😶)
19th Sep 2017, 3:52 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Hey, is there really any such one line code?
19th Sep 2017, 3:19 PM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
+ 1
I need code
19th Sep 2017, 3:18 PM
Rushikesh Chaudhari
Rushikesh Chaudhari - avatar