1

I am trying to create a UML class diagram for one of my classes and am unsure how to represent a certain element of the class. One of the methods within my class has a method within it. How would I represent this in the diagram?

public void start(){ ... @Override public void run(){ ... } } 

1 Answer 1

6

In java you can't have method inside method.

What you have is method inside anonymous class inside method.

So you have to put that anonymous class in your diagram and add method to it.

PS: Some languages allow method inside methods. In that case you do not add them to class diagram because those inner method is implementation details.

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

2 Comments

When you can't have methods inside methods, then the code fragment in the OP is incorrect, is it?
It may be correct if you replace ... to right code. Like void start() { new Runnable(){ public void run(){}};}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.