Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this apparently "random" numbers print "Java is Awesome"

How does this program print "Java is Awesome"?

String s = IntStream.of(1635148106, 544434464, 1936029505, 6647151)
                    .flatMap(e -> IntStream.range(0, 4).map(i -> e >> i * 8))
                    .mapToObj(i -> Character.toString((byte) i))
                    .collect(Collectors.joining());
System.out.println(s);
like image 432
Sandy Avatar asked Dec 04 '22 17:12

Sandy


1 Answers

A little help for you:

01001010 01100001 01110110 01100001 (avaJ)
00100000 01101001 01110011 00100000 ( si )
01000001 01110111 01100101 01110011 (sewA)
01101111 01101101 01100101           (emo)

Now read it backwards:

01100001 01110110 01100001 01001010
00100000 01110011 01101001 00100000
01110011 01100101 01110111 01000001
00000000 01100101 01101101 01101111

Which is nothing but:

1247901281
543781664
1098343795
1869440256
like image 159
Aniket Sahrawat Avatar answered Dec 26 '22 05:12

Aniket Sahrawat