In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the example analysis of Java code to kotlin code for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Java code to kotlin code, there is a paragraph "[firstPara, secondPara, thirdPara] = fourthPara" do not understand. It has been proved that it is indeed a writing method that can work normally. Since I have not seen this kind of writing before, and I have not found the source from the official tutorial, it is recorded here. Because the writing is too strange, the record does not mean that I recommend it.
The converted kotlin code is simplified and written as method 1.
Val rect = RectF ()
Rect [left, top, right] = bottom
The effect is the same before and after the conversion, and then I intend to further optimize the code after the conversion, but I don't understand it here, so I have to read it by comparing the code before the conversion.
Simplification of java code before conversion
RectF rect = new RectF ()
Rect.set (left
Top
Right
Bottom)
So I was surprised to find this way of writing.
If the above java code is transferred manually, I will probably convert it to the following writing, which is written as 2.
Val rect = RectF ()
Rect.set (left, top, right, bottom)
From the point of view of operation effect, writing method 1 is equivalent to writing method 2.
Since writing method 2 is obviously easier to understand than method 1, it is recommended to write method 2. The significance of this article is that we can understand when we see the way of writing method 1.
In method 1, hold down the Ctrol key and click on the square brackets, and the navigation will jump to the corresponding set method.
This is the end of this article on "sample analysis of Java code to kotlin code". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.