[Java novice] It's a very simple question while studying Java.

Asked 2 years ago, Updated 2 years ago, 18 views

Question 1. I was reading a Java book

   if(min>v) = min = x; 

I thought about a line of code, but I don't know why you skipped {} instead of if(min>v) {min=x};.

Question 2.

 invite (new ArrayList<String>() { { add("Harry"); add("Tony"); } } )

As far as I know, when using the anonymous class, use {} only once to describe the method and data inside. However, I don't understand why the above code used {} #2{}.

Please give me a good answer.

java

2022-09-21 15:13

1 Answers

Note.

https://src-bin.com/ko/q/e1a7d


2022-09-21 15:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.