Carly_Rose
Eternal Poster
Hello mga ka PHC in you're own opinion tagalog way hehehehe ano po ba purpose ng constructor sa java at ang parameter neto at method with parameter salamat po sa mga makakatulong medyo nalilito po kasi ako.
class phc
{
int getProd(int x, int y)
{
return x * y;
}
static void main(String[] a)
{
print("6 x 7 = " + getProd(6, 7)); //yun 6 and 7 arguments or data na ipapasa sa method na ma received ni parameter x, y
}
}
Salamat po sa pag reply kuya sobrang appreciated po.Constructor - para makapag create ka ng object na magagamit mo sa main sa syempre sa ibang class din.
kapag nakapag create ka na ng object magagamit mo na yung mga ginawa mong method sa loob ng class.
Parameter sa Contructor - pwede kang hindi na maglagay o kung meron man, ginagamit naman yan para ipasa yung value nung parameter sa field.
Thanks po kuya sa pag reply appreciated much.Method in Java
Code:class phc { int getProd(int x, int y) { return x * y; } static void main(String[] a) { print("6 x 7 = " + getProd(6, 7)); //yun 6 and 7 arguments or data na ipapasa sa method na ma received ni parameter x, y } }
para sa function ang method to avoid redundancy sa code para hindi mo palagi itype like sum = x + y
int is a keyword or data types & getProd naman ang method while parameter is yun tagasapo ng data na pinasa ni main which is 6 & 7