/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
class Author {
// Instance variables
private String firstName, lastName;
// Constructor
public Author(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
/*
Instance methods
*/
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return this.firstName + " " + this.lastName;
}
}
public class Main {
public static void main(String[] args) {
// create instance
Author author = new Author("Alaa", "Emam");
System.out.println(author); // print author => call toString method
}
}