Guest User

Untitled

a guest
Nov 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public class MyClass {
  2. private static void func1() { // со статик
  3. ...
  4. }
  5. }
  6.  
  7. public class MyClass {
  8. private void func1() { // без статик
  9. ...
  10. }
  11. }
  12.  
  13. private static int hugeCapacity(int minCapacity) {
  14. if (minCapacity < 0) // overflow
  15. throw new OutOfMemoryError();
  16. return (minCapacity > MAX_ARRAY_SIZE) ?
  17. Integer.MAX_VALUE :
  18. MAX_ARRAY_SIZE;
  19. }
  20.  
  21. public class Car {
  22.  
  23. private static double convertToMiles(double km){
  24. return km*0.621371192;
  25. }
  26. }
  27.  
  28. class Knight : Warrior {
  29. private Weapon createMainWeapon() {
  30. return new Sword();
  31. }
  32. private Dagger getDagger() {
  33. return null;
  34. }
  35. }
  36.  
  37. class Knight : Warrior {
  38. static int numberOfKnights;
  39. public Knight() {
  40. numberOfKnights++;
  41. }
  42. public static int getNumber() {
  43. return numberOfKnights;
  44. }
  45. }
  46.  
  47. class Squire {
  48. Knight master;
  49. public prepareForBattle() {
  50. ...
  51. }
  52. }
Add Comment
Please, Sign In to add comment