+ 2

Constructors

Java constructors are a damn heck!!

28th Feb 2018, 12:30 PM
erick morias
erick morias - avatar
5 Answers
+ 8
Erick Keep practising to write codes 👍 Good luck
28th Feb 2018, 1:42 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 5
Why?? Do you need help?😊
28th Feb 2018, 1:34 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 1
👍👍
28th Feb 2018, 2:24 PM
erick morias
erick morias - avatar
0
yeah, i always seem to forget or misplace them
28th Feb 2018, 1:40 PM
erick morias
erick morias - avatar
0
Hope this will help you guys! import java.util.Scanner; class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); String movie = read.nextLine(); int row = read.nextInt(); int seat = read.nextInt(); Ticket ticket = new Ticket(movie, row, seat); System.out.println("Movie: " + ticket.getMovie()); System.out.println("Row: " + ticket.getRow()); System.out.println("Seat: " + ticket.getSeat()); } } class Ticket { private String movie; private int row; private int seat; //complete the constructor public Ticket(String movie, int row, int seat) { this.movie = movie; this.row = row; this.seat = seat; } public String getMovie() { return movie; } public int getRow() { return row; } public int getSeat() { return seat; } } Happy coding!
13th Oct 2022, 11:00 AM
Kanagaraj Arunthadhy
Kanagaraj Arunthadhy - avatar