• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Difference between CharSequence and char[] in null reference during StringBuilder  RSS feed

 
Ranch Hand
Posts: 77
2
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Mr.Hanumant Deshmukh,

In another question, I also want to know the difference in CharSequence and char[] in null reference in StringBuilder. For this task, my program is written as follows.

During compilation, it raised compile-time error:
What happened when it is being converted to string from null?

Thank you
 
Bartender
Posts: 2218
47
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 5 append methods in StringBuilder with one parameter that is a reference. The compiler doesn't know which of these you want to invoke when passing null as this could be any of them.
You can help the compiler by adding a type information to the call:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!