Advertisement
sergAccount

Untitled

Aug 30th, 2020
1,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 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 com.spec;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class Main {    
  13.     //
  14.     public static void printStringLen(String s){
  15.         if(s!=null){
  16.             System.out.println("s.len=" + s.length());
  17.         }
  18.     }
  19.     //
  20.     public static void main(String[] args) {
  21.         // обработка исключений
  22.         Exception e; // переменная типа Exception, Exception - базовый класс для всех исключений
  23.         // пример исключения (возникновения исключения)
  24.         printStringLen("HELLO");
  25.         //
  26.         String s = "HELLO";
  27.         printStringLen(s);
  28.        
  29.         s = null;
  30.         if(s!=null){
  31.             printStringLen(s);
  32.         }                
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement