0

Help me with my best code i could't find where are the errors?

what I did wrong public class Program { public static void main(String[] args) { Program me = new hassan(); Program him = new amin () ; me.boy(); him.mama(); } } import java.util.*; public class hassan extends Program { public static boy (System.in) { int boy ; return boy; } } public class amin extends Program { public void mama() { System.out.println ("hay mom") ; } }

7th Jan 2017, 9:51 AM
HASAN
HASAN - avatar
4 Answers
+ 2
instead do it like this.. import java.util.*; public class Program { public static void main(String[] args) { hassan me = new hassan(); amin him = new amin() ; me.boy(System.in.nextInt()); him.mama(); } } public class hassan { public hassan (){} public static int boy (int x) { int boy = x; return boy; } } public class amin { public amin(){} public void mama() { System.out.println ("hay mom") ; } }
8th Jan 2017, 8:41 AM
Pankaj Vaghela
Pankaj Vaghela - avatar
+ 1
thanks a lot man
10th Jan 2017, 1:05 PM
HASAN
HASAN - avatar
+ 1
but there is something wrong with your code pls check it out and tell me what is the answer and again thank you for your help thanks a lot man
12th Jan 2017, 8:45 AM
HASAN
HASAN - avatar
0
yeash there was a problem... I modified it as follows. I tested it and it works fine You can check it here in playground or.... https://code.sololearn.com/cz3h7UUvHhJ0/?ref=app or just look this one import java.util.*; public class Program { public static void main(String[] args) { hassan me = new hassan(); amin him = new amin() ; Scanner scan = new Scanner(System.in); him.mama(); System.out.print( me.boy(scan.next()) ); } } public class hassan { public hassan (){} public static String boy (String x) { String boy = "I\'m "+x; return boy; } } public class amin { public amin(){} public void mama() { System.out.print("hay mom, ") ; } }
13th Jan 2017, 12:14 AM
Pankaj Vaghela
Pankaj Vaghela - avatar