Day 4 of code: Class vs Instance | hackerrank | java | tutorial

preview_player
Показать описание

- Java tutorials
Day 4 code of HackerRank solution in java. here is the complete solution using java 8
Using this video you can learn how to work with class & instances. oops concept

- Here is the blog link from there you can get solution of live competitions from different competitive programming sites

If you will get any problems in programming you can comment here and I will try to solve your problem as soon as possible.
you can also share your questions on the FB page given above
Рекомендации по теме
Комментарии
Автор

I am getting compilation message as wrong answer . I don't know why the output I am getting is of 13 lines but the expected output is of 12 lines . I have written the same code still it is showing me this "wrong ans" message

harleenkaur
Автор

Please help
I have written the same code as you have written, ,,,but still it is givng compilation error

suvratagnihotri
Автор

how to remove extra line in the output????

satishrajbanshi
Автор

Please can someone tell me why I'm getting these 'illegal start of expression' error messages when I try to compile on java? I've even put extra closed brackets in there so it can't be that and I'm very confused as to what the problem it... :(

public class Person { private int age;

public Person(int initialAge) {
// Add some more code to run some checks on initialAge
age = initialAge;
}


public void amIOld() {
// Write code determining if this person's age is old and print the correct statement:

if(age<0){
System.out.println("Age is not valid");
if(age<13){
System.out.println("You are young");
}
if(age >= 13 && age < 18){
System.out.println("You are a teenager");
}
else{
System.out.println("You are old");
}

}
public void yearPasses() {
// Increment this person's age.
age++;
}



Person.java:28: error: illegal start of expression
public void yearPasses() {
^
Person.java:28: error: illegal start of expression public void yearPasses() { ^ Person.java:28: error: ';' expected public void yearPasses() { ^ Person.java:34: error: illegal start of expression public static void main(String[] args) { ^ Person.java:34: error: illegal start of expression public static void main(String[] args) { ^ Person.java:34: error: ';' expected public static void main(String[] args) { ^ Person.java:34: error: '.class' expected public static void main(String[] args) { ^ Person.java:34: error: ';' expected public static void main(String[] args) { ^ Person.java:49: error: reached end of file while parsing } ^ 9 errors

marcz
join shbcf.ru