package bbb;
public class Person {
private String name;
private int age;
public Person(){
}
public Person(String name){
this.name = name;
}
public Person(int age){
this.age = age;
}
public Person(String name,int age){
this.name = name;
this.age = age;
}
public String getName(String name){
return name;
}
public void setName(String name){
this.name = name;
}
public int getage(int age){
return age;
}
public void setAge(int age){
if(age<0){
this.age=0;
}else{
this.age = age;
}
}
public void printMessage(){
System.out.println("name = "+name+",age = "+age);
}
public void addAge(){
age++;
}
}
package bbb;
public class TestPerson{
public static void main(String[] args) {
Person p1 = new Person(" Cai Xukun ",30);
p1.addAge();
p1.printMessage();
Person p2 = new Person(" Juen-Kai Wang ",20);
p2.addAge();
p2.printMessage();
Person p3 = new Person();
}
}
java More related articles on the fourth computer
- Java Four inner classes of
Java The four inner classes of are as follows : Member inner class Static inner class Local inner classes Anonymous inner class Member inner class : Defined in another class ( External class ) Internal , And the level with member methods and properties is called member inner class ,...... Non static methods equivalent to external classes ...
- Java Experiment four
20145113 Java Experiment four Shortcut key I didn't remember much before ISDEA Shortcut keys , But using shortcut keys skillfully can bring a lot of convenience , So I started to learn some common shortcut keys , Just use its default shortcut , So there won't be conflict later , some and ...
- Java There are four kinds of quotations in English : strong 、 soft 、 weak 、 Virtual reference
This article is great :http://alinazh.blog.51cto.com/5459270/1276173 Java There are four kinds of quotations in English : strong . soft . weak . Virtual reference 1.1. Strong reference when we use new When this keyword creates an object ...
- java There are four types of references in
java There are four types of references in Look at the code today , There is a class in it java.lang.ref.SoftReference Make me crazy , Just imagine , Contact java There has been a 3 It's been three years , even lang The classes under the package don't understand , How . Later on ...
- 《Thinking In Java The Fourth Edition 》 Pick up
<Thinking In Java The Fourth Edition > Pick up Self transforming github(http://katsurakkkk.github.io/2016/05/Thinking-In-Java%E7%AC ...
- Java In the fourth class, I started to use my brain
Java In the fourth class, I started to use my brain 1. see String.equals() Method public class StringEquals { /** * @param args the command ...
- Java Advanced ( forty-seven )Socket signal communication
Java Advanced ( forty-seven )Socket signal communication Today I'm going to talk about a Hello Word Grade Java Socket Examples of communication . The specific communication process is as follows : Start... First Server End , Entering a dead loop to listen to a port all the time is ...
- Java Advanced ( forty-three ) The difference between thread and process
Java Advanced ( forty-three ) The difference between thread and process 1. Basic concept of thread Concept : A thread is the smallest unit of execution in a process , Is an entity in the process , It is the basic unit independently scheduled and dispatched by the system , Thread does not own system resources , Only have a little in operation ...
- Java Advanced ( Forty-two )Java Multithreading uses anonymous inner classes to create 3 Ways of planting
Java Multithreading uses anonymous inner classes to create 3 Ways of planting package cn.edu.ujn.demo; // Anonymous inner class format : public class ThreadDemo { public st ...
Random recommendation
- java Multithreading ( Essence version )
stay Java It's better to use multithreading in a program than in C or C++ It's much easier in the middle , This is because Java Programming languages provide language level support . In this paper, through a simple programming example to illustrate Java How intuitive multithreading is in a program . After reading this article , Users should ...
- SQL--Order By
Order By-- The current query data results , Sort , Sort by the column specified later ; DESC-- Reverse sort ( Descending ); ASC-- Positive sequence sort ( Ascending ); Chinese characters : Sort by the initials of Pinyin , Ascending order is from a--z; Descending order is from z ...
- cocos2d-x Use UIWebView Load web page ( By the way, you can see how to use OC transfer C++)
Monkey original , Welcome to reprint . Reprint please indicate : Reprinted from Cocos2D Development Network –Cocos2Dev.com, thank you ! Original address : http://www.cocos2dev.com/?p=248 Some time ago, the project was authorized to log on by microblog ...
- HDU 1695 GCD Euler function + The inclusion exclusion theorem
Input a b c d k Ask how many are right x y bring x stay a-b Section y stay c-d Section gcd(x, y) = k Besides a and c It must be 1 because gcd(x, y) == k take b and d All divided by k The title translates into 1 To b/k and ...
- Linux Under the fork()【 Reprint 】
[ Original address ]http://blog.csdn.net/hikaliv/article/details/4276758 [cpp] view plaincopy for( i = 0; i < ...
- Java-Maven( 7、 ... and ):Eclipse in Maven rely on 、 polymerization 、 Inheritance features
I learned about ,maven Integrated into the eclipse How to create a project in , as well as maven The command plug-in is eclipse Usage after installation in . So next we're going to learn some maven Some features in the project , And how to use . Maven ...
- K3 Data dictionary for reference
select distinct f.FNumber as System code , f.FName AS System name , d.FTableName AS Table name ,d.FDescription AS Table description ,a.[nam ...
- In depth understanding of JVM( 7、 ... and )—— Performance monitoring tools
Preface If a worker wants to do a good job, he must sharpen his tools first , Performance optimization and troubleshooting in the eyes of most of us is a relatively difficult thing , First, we need to have certain principle knowledge as the basis , Second, we need to master the process of troubleshooting and solving problems . Method . This article will introduce the use of performance monitoring tools , Help to open ...
- use indexof To count the number of times characters appear
The code is as follows : <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- Write your... In this format distributionUrl, You can use local gradle package
distributionUrl=file\:/C:/Users/shenliuyong/.gradle/wrapper/dists/gradle-2.10-all/a4w5fzrkeut1ox71xs ...