← Back to feed
Renewal·서른의 생활코딩

ex5) Java OOP - Method Overloading

NS
normalstory
cover image

/*
class Box {
int width;
int height;
int depth;
long idNum;              // ->| 4 access modifier omitted data member 
// new operator each time declared memory creation
static long boxID = 0; // (static data member = class variable) declaration !!
public Box() {                   // creation Resulttype(void) usenot possible 
idNum = boxID++;    //before this. omittedomitted.
// creation executioneach time class variable value increase
}
public void Dispaly(){
System.out.println( width +""+ height +""+ depth +"="+idNum);
}
}
public class Oop01 {
public static void main(String[] args) {
//System.out.print(b1.boxID);  //not yet declaration not -> error!
System.out.print(Box.boxID);  //same memory space means.
Box b1 = new Box();
//Box b1 = new Box(12);   // corresponding creation not found error!
Box b2 = new Box();
b1.Dispaly();
b2.Dispaly();
System.out.print(b1.boxID);  //declaration -> success
System.out.print(b2.boxID);  //same memory space means.
System.out.print(Box.boxID);  //same memory space means.
}

}

**/




class Box {
int width;
int height;
int depth;
long idNum;               // ->| 4 access modifier omitted data member 
// new operator each time declared memory creation
static long boxID = 0; // (static data member = class variable) declaration !!
public Box() {                  // Resulttype(void) usenot possible 
idNum = boxID++;   //before this. omittedomitted.
                             // creation executioneach time class variable value increase
}
public void Dispaly(){
System.out.println( width +""+ height +""+ depth +"="+idNum);
}
}
public class Oop01 {
static{                 //memory continuously stored and then, program when terminating deletes.
System.out.println(Box.boxID);
System.out.println("mainfunction execution previous memory first definitionsince it was access bypossible");
                 //System.out.println(b1.boxID); //not yet new declaration was not.
}
public static void main(String[] args) {
//System.out.println(b1.boxID);  //not yet declaration not -> error!
System.out.println(Box.boxID);   //same memory space means.
Box b1 = new Box();
//Box b1 = new Box(12);         // corresponding creation not found error!
Box b2 = new Box();
b1.Dispaly();
b2.Dispaly();
System.out.println(b1.boxID);    //declaration -> success
System.out.println(b2.boxID);    //same memory space means.
}

}

  • Open in Google Docs Viewer
  • Open link in new tab
  • Open link in new window
  • Open link in new incognito window
  • Download file
  • Copy link address
  • Edit PDF File on PDFescape.com

element

Font
font-family
font-size
font-style
font-variant
font-weight
letter-spacing
line-height
text-decoration
text-align
text-indent
text-transform
white-space
word-spacing
color
Background
bg-attachment
bg-color
bg-image
bg-position
bg-repeat
Box
width
height
border-top
border-right
border-bottom
border-left
margin
padding
max-height
min-height
max-width
min-width
outline-color
outline-style
outline-width
Positioning
position
top
bottom
right
left
float
display
clear
z-index
List
list-style-image
list-style-type
list-style-position
Table
vertical-align
border-collapse
border-spacing
caption-side
empty-cells
table-layout
Effects
text-shadow
-webkit-box-shadow
border-radius
Other
overflow
cursor
visibility

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.