ya_zay4eg

level10.lesson04.task01

Jan 25th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package com.javarush.test.level10.lesson04.task01;
  2.  
  3. /* Задача №1 на преобразование целых типов
  4. Расставь где нужно оператор приведения типа:
  5. byte a = 1234;
  6. int b = a;
  7. byte c = a * a;
  8. int d = a / c;
  9. */
  10.  
  11. public class Solution
  12. {
  13.     public static void main(String[] args)
  14.     {
  15.         byte a = (byte) 1234; //обрезаем int к (byte)
  16.         int b = a; //(here is nothing to do int is BIG and a(byte) freely fits)
  17.         byte c = (byte)(a *a);// the result of (a*a) must be byte and we byte(it)
  18.         int d = a / c;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment