diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java index 068c4ccf00..79131ebac8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanPropertyName.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,12 +44,12 @@ abstract class BeanPropertyName { */ public static String toDashedForm(String name, int start) { StringBuilder result = new StringBuilder(); - char[] chars = name.replace("_", "-").toCharArray(); - for (int i = start; i < chars.length; i++) { - char ch = chars[i]; + String replaced = name.replace('_', '-'); + for (int i = start; i < replaced.length(); i++) { + char ch = replaced.charAt(i); if (Character.isUpperCase(ch) && result.length() > 0 && result.charAt(result.length() - 1) != '-') { - result.append("-"); + result.append('-'); } result.append(Character.toLowerCase(ch)); }