检测到您已登录华为云国际站账号,为了您更好的体验,建议您访问国际站服务网站 https://www.huaweicloud.com/intl/zh-cn
不再显示此消息
重构前 class SafeDelete { private void foo(int i) { bar(i);} private void bar(int i) { baz(i);} private void baz(int i) { } } 重构后 class
{ private int a; private int b; public void InlineMethod() { int c = add(a, b); int d = add(a, c); } private int
print(innerClass); } private static void print(InnerClass innerClass) { innerClass.print(); } private static class InnerClass
InnerClass(); innerClass.print(); } private static class InnerClass { private final NextClass nextClass = new NextClass();
} private static class TextContainer { private final String hello; private final String world; private TextContainer(String
newInnerClass("Hello", "World").print(); } private static class InnerClass { private String message; private InnerClass(String hello, String
ExtractDelegate().print(); } private static final String message = "Hello World!"; private void print() { System.out.println(message);
new InnerClass().print(); } private static class InnerClass extends AbstractClass { } private static abstract class AbstractClass
InnerClass("Hello", "World").print(); } private static class InnerClass { private String message; public InnerClass(String
Hello World!"。 重构前 class InlineField { private String message = "Hello World!"; private void InlineField() { System.out.println(message);
MyTestClass(str, i); } private static class MyTestClass extends TestClass { private final String str; private final int i; public
sayHello(); } private static void sayHello() { sayHello("Hello" + " " + "World!"); } private static void sayHello(String
Printer(text, n).invoke(); } private static class Printer { private String text; private int n; public Printer(String
示例 例如,让我们内联参数pi,将其替换为参数的值Math.PI。 重构前 class InlineParameter { private double InlineParameter(double rad, double pi) { return pi *
检查弹性云服务器的防火墙是否允许当前该主机使用的proxy代理配置的出口IP作为入口IP。 请确认网络ACL没有禁用当前该主机使用的proxy代理配置的出口IP。 请检查与远程主机之间的网络连通,如需要可绑定弹性公网IP(EIP)。 父主题: 新建主机连接常见问题
main(String[] args) { System.out.println(generateText()); } private static String generateText() { return "Hello World!".toUpperCase();
returnNewValue() { ... } } class SubClass extends InlineSuperClass { private int myValue; int someMethod() { if (myValue > returnValue())
从集合ArrayList<String>迁移到数组String[]。 重构前 class TypeMigration { private ArrayList<String> myResult; public String[] getResult() {
static List<Integer> staticList; static int[] staticN; private static final String staticStr = "test"; public static void staticMethod()
public static void main(String[] args) { sayHello(); } private static void sayHello() { System.out.println("Hello" + " " +