Advertisement
sergAccount

Untitled

Sep 27th, 2020
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package myapp8;
  7. //
  8. public class MyApp8 {    
  9.     // определение (объявление метода) который выполняет
  10.     // сложение двух целых чисел
  11.     // 1) у метода есть имя
  12.     // 2) тип возвращаемого значения метода
  13.     // add - имя (название) метода
  14.     public static int add(int a, int b){
  15.         return (a + b);
  16.     }
  17.     //
  18.     public static void main(String[] args) {
  19.         // TODO code application logic here
  20.         // методы
  21.         int c = 10 + 20;
  22.         System.out.println(c);
  23.         // вызываем метод add
  24.         int result = add(10, 15);
  25.         System.out.println("Результат работы метода=");
  26.         System.out.println(result);
  27.         result = add(100, 77);
  28.         System.out.println(result);
  29.        
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement