📜  java oop - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:24.639000             🧑  作者: Mango

代码示例2
public class YourClass {
  String example;
  int test;
  
  // Constructor
  public YourClass(String example, int test) {
    this.example = example;
    this.test = test;
  }
  
  // Method
  public void someMethod() {
    System.out.println(example); 
  }
}

// Usage:
// Construct
YourClass exampleObject = new YourClass("Hello World!", 5);
// Execute Method:
exampleObject.someMethod();