Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views1 page

Author Java

The document defines an Author class in Java, which includes properties for author ID, first name, and last name. It provides two constructors: one for loading an author from a database with an ID and another for creating a new author without an ID. The class also includes getter and setter methods for its properties and a toString method for displaying author information.

Uploaded by

alperenaggumus0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Author Java

The document defines an Author class in Java, which includes properties for author ID, first name, and last name. It provides two constructors: one for loading an author from a database with an ID and another for creating a new author without an ID. The class also includes getter and setter methods for its properties and a toString method for displaying author information.

Uploaded by

alperenaggumus0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package com.example.

authorapp;

public class Author {


private int authorId;
private String firstName;
private String lastName;

// Constructor for loading from DB (with ID)


public Author(int authorId, String firstName, String lastName) {
this.authorId = authorId;
this.firstName = firstName;
this.lastName = lastName;
}

// Constructor for creating new author (without ID before DB insert)


public Author(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

public int getAuthorId() {


return authorId;
}

public void setAuthorId(int authorId) {


this.authorId = authorId;
}

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 "Author{" +
"authorId=" + authorId +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
}

You might also like