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+ package com .premaseem ;
2+
3+ /*
4+ @author: Aseem Jain
5+ @title: Design Patterns with Java 9
6+ @link: https://premaseem.wordpress.com/category/computers/design-patterns/
7+ */
8+ public class Calculator {
9+
10+ public Integer add (Integer sum , Integer number ){
11+ return sum + number ;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ package com .premaseem ;
2+
3+ /*
4+ @author: Aseem Jain
5+ @title: Design Patterns with Java 9
6+ @link: https://premaseem.wordpress.com/category/computers/design-patterns/
7+ @copyright: 2018 Packt Publication
8+ */
9+ public class Client {
10+ public static void main (String [] args ) {
11+ System .out .println ("program to add number" );
12+ Integer sum = calculateSum ();
13+ System .out .println ("total of all numbers is " + sum );
14+ }
15+
16+ private static Integer calculateSum () {
17+ Integer sum = 0 ;
18+ for (int i =0 ; i < 1000 ; i ++){
19+ Calculator calc = new Calculator ();
20+ sum = calc .add (sum ,i );
21+ }
22+ return sum ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments