• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Core Java: Class and Object

 
sailaja cherukuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package objectconcept;

class Object1
{
static int papercount=0;
static void print()
{
if(papercount>0)
{
papercount=papercount-1;
System.out.println("Documented printed");
}
else
{
System.out.println("please load the paper in the tray");
}
}
void printDocument()
{
print();
}
}
....................

package objectconcept;

class PrintObject
{
public static void main(String args[])
{
PrintObject p1= new PrintObject();
PrintObject p2=new PrintObject();
p1.PrintDocument();
p2.PrintDocument();
}
}
......................

hii In first program i wrote static and non static.. ( class level and object level) ... with out main method.. so it is compiledd......
In 2nd program i create an object for non static(object level) ... but for 2nd program i am getting an errorss as

PrintObject.java:9: error cannot find symbol
p1.PrintDocument();

symbol: method PrintDocument()
location: variable p2 of type PrintObject
2 errors


 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your PrintObject class doesn't have a PrintDocument method.
 
sailaja cherukuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using class object1 there is void printDocument() method .. this method i am using in class PrintObject program....... check it once..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sailaja cherukuri wrote:check it once..

Why don't you check it? PrintDocument is not the same as printDocument.
 
sailaja cherukuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha....... yaya i got it noww....... i check it ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic