File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ public class FizzBuzz {
2+
3+ /**
4+ * Write a program that prints the numbers from 1 to 100 and for multiples of '3' print "Fizz"
5+ * instead of the number and for the multiples of '5' print "Buzz".
6+ * @param args
7+ */
8+ public static void main (String [] args ) {
9+
10+
11+ System .out .println ("FizzBuzz" );
12+
13+ for (int i =1 ; i <=100 ; i ++){
14+ if (i % 3 == 0 && i % 5 ==0 ){
15+ System .out .println ("FizzBuzz" );
16+ } else if (i % 5 ==0 ){
17+ System .out .println ("Buzz" );
18+ } else if (i % 3 ==0 ){
19+ System .out .println ("Fizz" );
20+ } else {
21+ System .out .println (i );
22+ }
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package com .intuit .webs .java8 ;
2+
3+ public class RunnableLambdaInterface {
4+
5+ //old-way annonymous class
6+ public static void main (String [] args ) {
7+
8+ Runnable runnable = new Runnable () {
9+ @ Override
10+ public void run () {
11+ System .out .println ("inside runnable run1" );
12+ }
13+ };
14+ new Thread (runnable ).start ();
15+
16+ //Lambda () -> {};
17+ Runnable runnable1 = () -> {
18+ System .out .println ("inside runnable run2" );
19+ };
20+ new Thread (runnable1 ).start ();
21+
22+
23+ Runnable runnable2 = () -> System .out .println ("inside runnable run2" );
24+
25+ //3rd way
26+ new Thread (() -> System .out .println ("inside 3" )).start ();
27+
28+ }
29+
30+
31+
32+ }
You can’t perform that action at this time.
0 commit comments