Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
public class person
{
    
    //instance variable 
    Private_String name;
    Private_int age;
    Person()
    {
        name = "Raju";
        age = 22;
    }
    
    //method
    void talk()
    {
        System.out.println("hello my name is" + name);
        System.out.println("my age is" + age);
    }
    
}
public class demo
{
    public static void main(String args[])
    {
        //create person class object: Raju
        Person Raju = new Persom();
        //call the talk method
        Raju.talk();
    }
}


What I have tried:

[I wrote some code]
Posted
Updated 12-Dec-17 22:02pm
v2

 
Share this answer
 
That isn't Javascript: it's Java. Please tag your posts with the correct language ... it makes our job a lot easier and that means you get better results.

Private_String isn't declared anywhere there, and I'd guess that it's not what you wanted.
Try this:
//instance variable
private String name;
private Int age;
public Person()
{
    name = "Raju";
    age = 22;
}

//method
public void talk()
{
    System.out.println("hello my name is" + name);
    System.out.println("my age is" + age);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900