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.

Recommended Answers

All 3 Replies

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

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.

No problem. Any time you get stuck, we'll be here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.