Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How many parameters can be used by a Java method

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how many parameters can be used by a Java method". In daily operation, I believe many people have doubts about how many parameters a Java method can use. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the doubt of "how many parameters can be used in a Java method". Next, please follow the editor to study!

I recently added an interface to my fork project QuickTheories:

@ FunctionalInterface public interface QuadFunction {E apply (An a, B b, C c, D d);}

This makes it very curious how many type parameters a method can have. As far as I know, the language specification of Java does not mention this issue. one

I have two guesses about the definition of this threshold in implementation:

The compiler enforces a predictable threshold, such as 255or 65535.

Because of the implementation details, the compiler's exception handling imposes unexpected restrictions.

I didn't want to test the source code with my weak C++ skills, so I decided to test Compiler 2 directly. I wrote a Python script to find a minimum value that would trigger an error through dichotomy. For the complete code, see connection Github Repo.

The most direct way is to generate the method. Fortunately, we don't have to use any of the existing type parameters, just follow the

Def write_type_plain (count): with open ('Test.java', 'w') as f: f.write ("public class Test {\ n") f.write ("public void testMethod () {}") f.write ("}")

The code that runs this dichotomy will have the following output:

> error: UTF8 representation for string "

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report