Advertisement
Svetlana_Ovsjanikova

Java - exceptions

Sep 21st, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 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 day7_exceptions;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author sao_7
  13. */
  14. public class Day7_exceptions {
  15.  
  16. /**
  17. * @param args the command line arguments
  18. */
  19. public static void main(String[] args) {
  20. //examples();
  21. exercise(); // kods nestraadaa
  22. }
  23.  
  24. public static void examples(){
  25.  
  26. int[] arr = new int[5];
  27.  
  28. try{
  29. for (int i = 0; i < 6; i++) {
  30. arr[i] = i+1;
  31. System.out.println(arr[i]);
  32. }
  33. }catch(Exception ex){
  34. System.out.println("nokeram");
  35.  
  36. }
  37. System.out.println("peec kluudas");
  38. }
  39.  
  40. //Uztaisitt metodi, kur cilveks ievada masiva garumu
  41. //ar ciklu aizpildam masivu ar vertibam (integer, vai string)
  42. //tad cilveks ievada kuru elementu mes mainam
  43. //tad izvadam masivu
  44.  
  45. public static void exercise(int[] arr){
  46. Scanner sc = new Scanner(System.in);
  47. int[] i = new int[10];
  48.  
  49. try{
  50. for (int j = 0; j < 10; j++) {
  51. i[j] = j+1;
  52. System.out.println(i[j]);
  53. }
  54. }catch(Exception ex){
  55.  
  56. }
  57.  
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement