nag papract ako mag oop yan kasi topic namin now kaya nag dl ako jk at ide bat po ganto ayaw mag run? tama naman code ko
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
new_pract = new new_pract ()
new_pract = new new_pract()
newPract = new newPract()
and sa classes naman, gumamit ka ng Pascal case: Practice
, ThisIsMyClass
package com.mycompany.pract;
opo galing c++ nag transfer kasi tapos iba pala language nila ayun btw thanks bossMukhang galing kang c++ ah.
1. Tanggalin mo yung space before ng parenthesis when calling a function/method.
Example: This same goes sa scanner mo.
Instead of:new_pract = new new_pract ()
Do:new_pract = new new_pract()
2. You can name your scanner with in instead of cin. Tho, ikaw naman bahala pero ito yung lagi kong ginagawa since mabilis.
3. Naming variables and classes: Sa variable at function, gumamit ka ng camel case:newPract = new newPract()
and sa classes naman, gumamit ka ng Pascal case:Practice
,ThisIsMyClass
4. You can use System.out.print sa mga kasunod is input para walang new line
5. Maeencounter mo yung error sa magkasunod na input na nextInt at nextLine and hindi mababasa yung isa. Yung solution is lagyan mo muna ng nextLine() after ng nextInt().
int num = in.nextInt();
in.nextLine();
String text = in.next();
thanks poTingnan mo yung project explorer mo sa left side. yung "Pract.java" mo nasa loob ng "default package" dapat yan nasa loob ng "com.mycompany.pract". So ililipat mo lang yan via dragging it. Tapos type mo ito sa tuktok ng file (sa pinakaunahan)
Java:package com.mycompany.pract;