Sunteți pe pagina 1din 1

Balbuena, Chester Gil D.

8/29/17
Activity 29

package balbuena4;

public class Proj4 {


public static String name;
public static String screenName;

balbuena4 is the name of the package. A package is for organizing classes.


The semicolon in the end indicates that the statement is terminated. Proj4 is
the class name. Public is a keyword which means that any other classes can
access public field or a method. Static is keyword that only belongs to the
class rather than instance of a class. String is an object. name and
screeName are variable name.

public Proj4 (String nm, String sn){


name = nm;
screenName= sn;
}

Proj4 is a constructor, because it has the same name as the class.


Parentheses are used to supply parameters.

public static void main (String[] args) {

Proj4 c1 = new Proj4 ("John Doe", "John Deer");


System.out.println(name);
System.out.println(screenName);
}

Void is a return data type which means it does not return any value. Main is
method. String args[]is a command line argument it is a collection of
variables in the string format. New is a keyword that creates object. System
is a class. Out is a static member of the system class. Println is a method
which prints the argument

S-ar putea să vă placă și