Advertisement
apl-mhd

OOP static variable

May 30th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class StudentInfo {
  4.  
  5.     int id;
  6.     String name;
  7.     static  String uni = "United International University ";
  8.  
  9.     StudentInfo(int i, String nm){
  10.  
  11.         id = i;
  12.         name = nm;
  13. /*
  14.         System.out.println("Id: 0"+id);
  15.         System.out.println("Name: "+name);
  16.         System.out.println("University: "+uni);
  17.         System.out.println();
  18. */
  19.     }
  20.  
  21.     void display(){
  22.  
  23.         System.out.println("Id: 0"+id);
  24.         System.out.println("Name: "+name);
  25.         System.out.println("University: "+uni);
  26.         System.out.println();
  27.  
  28.     }
  29.  
  30.  
  31.  
  32.  
  33.     public static void main(String[] args) {
  34.  
  35.         StudentInfo one = new StudentInfo(11161036,"Orko");
  36.         StudentInfo two = new StudentInfo(11161234,"Orion Hunter");
  37.  
  38.         one.display();
  39.         two.display();
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement