0

I can't remember what it's called when another class's method in java for example in a main class you call the scanner class to scan in user input?

1
  • eh, a method/operation invocation? Commented Nov 30, 2010 at 15:04

4 Answers 4

2

I think you're looking for the names of associations like aggregation and composition. The terms are used to describe Releationships in UML

Sign up to request clarification or add additional context in comments.

2 Comments

Is this the terminology to be used in UML diagramming?
Yes - I will add references as links
1

Your question is not clear.

but maybe the following example will help:

class Scanner{
  public void scan(){}
}

//use inheritance
class SubScanner extends Scanner{
  public void scan(){}       //overriding
  public void scan(int i){}  //overloading
}

//use aggreagation
class MainClass{
  private final Scanner scanner;
  MainClass(Scanner scanner){
    this.scanner = scanner;
  }
  public void scan(){ 
    scanner.scan();         //delegation call
  }
}

Comments

1

If the scan method is an instance (object) method (not static), it would be something like this

Scanner s = new Scanner();
s.scan();

If scan is static (a class method), then

Scanner.scan();

Edit: The name of the relationship is Dependency in UML. You say that Main depends on Scanner or Main uses-a Scanner. I made this UML slideshow and cheatsheet:

http://www.loufranco.com/blog/files/UMLCheatsheet.html

If you have a Scanner member in the main class, then this is usually called has-a, composition, or an association.

2 Comments

That's not what I'm after, I'm looking for what the name of the relationship would be between two classes of the example I provided.
It's called Uses-a or depends-on in UML.
0

Here is a table of many UML relationships

http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic=/com.ibm.xtools.modeler.doc/topics/rreltyp.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.