0

Hey Can someone explain to me what, Method, Class and args are?...explain it like I'm a complete idiot btw. THANK YOU

Java Key Words

20th Aug 2018, 2:50 PM
NanoMyte
2 odpowiedzi
0
Hey NanoMyte, to explain each of these keywords I'll use an example. Imagine a university, a big and famous one with many students. Let's say the university has a Java program that lets each student view useful information as well as perform actions such as registering to courses and exams. Now we need to create that program. Let's start with the students, we need to somehow represent each student individually, that's where classes come useful. A class contains arguments and methods which are mostly unique only to that class. So we name our class Student and each student has their own values to general arguments, for example a name, one student can be named Chris Brown while the other is named Jim Jones. Same happenes with Age, Gender and Student ID. So in the practical view we have String name; int age; String gender; Long UserID; Now each student also has the courses they're registered to, so we'll add an array called courses that will contain those. String[] courses = {"Introduction to Java"}
20th Aug 2018, 9:17 PM
Eldar Bakerman
0
Arguments (mostly called members) are basically unique identifiers of each student. And now we come to the methods. Methods are the action our student can perform, for example register to courses. So we have a method called registerToCourse that will prompt for the name and ID of the course as well as the semester and will add that course to the student's courses array. To learn more about these keywords search on Google "Introduction to Object Oriented Programming in Java"
20th Aug 2018, 9:21 PM
Eldar Bakerman