🔒 Closed Patulong po sa mga function nito. nahihirapan lang po ako ipaliwanag

Status
Not open for further replies.

euls020

Enthusiast
public class Displayer { --- 1.
public static void main(String args[]) { --- 2.
System.out.println("You'll love Java!"); --- 3.
} --- 4.
} --- 5.

Ano po function ng mga yan. patulong po medyo nalilito po ako eh. 3, 4 at 5 lang po alam ko eh. nalilito pa po ako kung ano pinag kaiba ng dalawang bracket ang alam ko lang po parehas silang nag coclose ng program para di mag ulit ang output. ty po sa tutulong.
 
Public class is for your main of code in java

Kapag wala yan di gagana

Ung public static naman need siya kapag mag ttype ka ng code . Kailangan yan lalo na kung straight ka mag code .

Anung course mo ?

BSCS 301- HERE
 
Public class is for your main of code in java

Kapag wala yan di gagana

Ung public static naman need siya kapag mag ttype ka ng code . Kailangan yan lalo na kung straight ka mag code .

Anung course mo ?

BSCS 301- HERE
Ty po hehehe. beginner palang po grade 12 ICT. ty po ng marami
 
Code:
public class Displayer {
public is an access modifier. It simply means that whatever it's applied to can be seen by external classes and classes outside the module.

class means you're declaring a class, and

Displayer is the name of the class

For number 1, it means you're declaring a publicly visible class named "Displayer".
You do not have permission to view the full content of this post. Log in or register now. is the official documentation from Java™ tutorials

Code:
public static void main(String args[]) {
static means you're defining a class method.

Class methods (commonly referred to as static methods) are functions that belong to the class and is shared by all instances of that class. This means you don't need to create an object to invoke this method. static can be used in methods and fields; I'll just refer you You do not have permission to view the full content of this post. Log in or register now. for more info

public static void main(String args[]) {
is the method signature: it should have (optional) modifiers, return type, method name, parameter list, and exception list.

For number 2, you're defining a publicly visible class method called "main" that takes an array of String named "args" as an argument, and returns nothing (void). A matching pair of brackets encloses the method body.
Again, You do not have permission to view the full content of this post. Log in or register now. a link to the docs

Code:
System.out.println("You'll love Java!");
System.out.println(); is a call on method named "println".

We observe that class System has a static field "out" which is an instance of PrintStream. It prints to the standard output and you invoke one of its methods, println (print line), to do just that.

Note the semicolon. It terminates a statement, in our case the statement is a method call. For now, just remember that it is necessary to terminate all statements because it's the syntax of java.

"You'll love Java!"
we omitted this from the above explanation. This is the string that you pass to the method call above. Stitching everything together, number 3 is a statement that roughly translates to:

Invoke the [method println of object out] on [class System] with the string "You'll love Java!" as an argument -- done.

Code:
}
}
These two closing curly brackets are simple: brackets enclose "bodies" and blocks (a group of statements):
  • number 4 is the closing brackets for the [body of the static method main].
  • number 5 is the closing brackets for the [body of the class Displayer].
 
Code:
public class Displayer {
public is an access modifier. It simply means that whatever it's applied to can be seen by external classes and classes outside the module.

class means you're declaring a class, and

Displayer is the name of the class

For number 1, it means you're declaring a publicly visible class named "Displayer".
You do not have permission to view the full content of this post. Log in or register now. is the official documentation from Java™ tutorials

Code:
public static void main(String args[]) {
static means you're defining a class method.

Class methods (commonly referred to as static methods) are functions that belong to the class and is shared by all instances of that class. This means you don't need to create an object to invoke this method. static can be used in methods and fields; I'll just refer you You do not have permission to view the full content of this post. Log in or register now. for more info

public static void main(String args[]) {
is the method signature: it should have (optional) modifiers, return type, method name, parameter list, and exception list.

For number 2, you're defining a publicly visible class method called "main" that takes an array of String named "args" as an argument, and returns nothing (void). A matching pair of brackets encloses the method body.
Again, You do not have permission to view the full content of this post. Log in or register now. a link to the docs

Code:
System.out.println("You'll love Java!");
System.out.println(); is a call on method named "println".

We observe that class System has a static field "out" which is an instance of PrintStream. It prints to the standard output and you invoke one of its methods, println (print line), to do just that.

Note the semicolon. It terminates a statement, in our case the statement is a method call. For now, just remember that it is necessary to terminate all statements because it's the syntax of java.

"You'll love Java!"
we omitted this from the above explanation. This is the string that you pass to the method call above. Stitching everything together, number 3 is a statement that roughly translates to:

Invoke the [method println of object out] on [class System] with the string "You'll love Java!" as an argument -- done.

Code:
}
}
These two closing curly brackets are simple: brackets enclose "bodies" and blocks (a group of statements):
  • number 4 is the closing brackets for the [body of the static method main].
  • number 5 is the closing brackets for the [body of the class Displayer].
yun naman. salamat po idol
 
Public class Displayer - is the name of class
Public static void main(String args[]) - is your main method kailangan mu yan para ma run mu code mu.
System.out.println(); - is mag didisplay nang kahit anong texr ilagay mu jan.
 
Status
Not open for further replies.

About this Thread

  • 10
    Replies
  • 889
    Views
  • 5
    Participants
Last reply from:
Beetelguess

Trending Topics

Online now

Members online
1,250
Guests online
1,038
Total visitors
2,288

Forum statistics

Threads
2,273,186
Posts
28,948,061
Members
1,235,655
Latest member
hkql
Back
Top