Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String - can you improve my poor code?

 
Marco Vanoli
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting string "value" a want a new one "setValue"..



This work but i don' t like it, somone have a best way to get the same result?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String myMethod = "set" + s.substring(0, 1).toUpperCase() + s.substring(1);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic