第十二周
Last updated
Last updated
本周任务如下:
注册OnlineGDB并且加入课程群:
完成Person Class作业
An instance variable can be assigned an initial value in its declaration, just like any other variable. For example, consider a class named Person. An object of this class will represent a person. It will contain three instance variables to represent its name, email and phone number:
The '@' symbol is a crucial component of the syntax for email addresses. According to the standard format,
Your task is to add a method isValidEmail() to this class that checks if the person's email contains the '@' . This method should return true
if the email contains '@', and false
otherwise.
The method signature should be:
public boolean isValidEmail()
Create a driver class. Paste the code here. Create the following two Person Objects in the driver class.
Click test, then you can see the result.
email address consists of two main parts: a local part and a domain part. These two parts are separated by the '@' symbol. For example, in the email address "", "example" is the local part, and "example.com" is the domain part.