Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing methods HELP!

 
Naf Rash
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you access/invoke a method from another class? Please could you provide an example.
 
David Maddox
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok here is an example
public class Dog{
public void bark(){
}
}

public class dogTest{
Dog dog= new Dog(); /*you create a dog object and it has all of its methods/*
dog.bark();
}
[ February 26, 2004: Message edited by: David Maddox ]
[ February 26, 2004: Message edited by: David Maddox ]
 
Naf Rash
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you may have forgotten to post the example! Thanks.
 
Naf Rash
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ignore what I just said for some reason the code did not load earlier on. Sorry.
 
David Maddox
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i hit the wrong button
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic