0

Hey guys,
so i'm trying to learn the basics of Java, i just could not understand this code.

public class Puppy{

   int puppyAge;

   public Puppy(String name){
      System.out.println("Passed Name is :" + name ); 
   }
   public void setAge( int age ){
       puppyAge = age;
   }

   public int getAge( ){
       System.out.println("Puppy's age is :" + puppyAge ); 
       return puppyAge;
   }
   public static void main(String []args){
      Puppy myPuppy = new Puppy( "tommy" );
      myPuppy.setAge( 2 );
      myPuppy.getAge( );
      System.out.println("Variable Value :" + myPuppy.puppyAge ); 
   }
}

now i know Python and C, so i understand basic syntex.

Could someone explain this could with deep detail? line by line?

Thanks for the help.

2
Contributors
3
Replies
22
Views
3 Years
Discussion Span
Last Post by JamesCherrill
0

Could someone explain this could with deep detail? line by line?

I doubt anyone has the time or motivation to do that. Look at some beginner's tutorials, and come back here with any specific questions that may remain.
This is a really good place to start

0

Yeah i just read a couple more websites and i understood the whole code!
Sorry for the empty post guys, should've looked more, my mistake.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.