Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8581293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:00:48+00:00 2026-06-11T21:00:48+00:00

to show the default value of char ,I wrote code like this: public class

  • 0

to show the default value of char ,I wrote code like this:

public class TestChar {
  static char a;
  public static void main(String[] args) {
    System.out.println("."+String.valueOf(a)+".");
    System.out.println("the default char is "+a);
  }   
}

but the console output is confused.the first is “. .” ,however the second is “the default char is [](like this ,I don’t know how to describe it.)” why?thanks for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:00:49+00:00Added an answer on June 11, 2026 at 9:00 pm

    As user1681360 mentioned, it is the character '\0' you are printing. You have not initialized your field, so Java initializes it for you to the default value, unprintable character '\0'. Depending on the environment, unprintable characters will be shown as empty boxes, question marks, etc.

    In the first line you are first creating a String, then appending it. In the second line the operator String + char is compiled to java.lang.StringBuilder#append(char), so you are directly appending a character to the buffer, rather that creating a temporary String.

    Indeed the two approaches are always equivalent, even when the character in question is '\0'. The character '\0' has a special treatment in Java Language Specification, but that does not affect this particular behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna show a picture inside the default value of a text field. this
The default show template places an g:if test=${domainInstance?.fieldName} around each domain class field. The
I would like to find out how to set the default value for the
I want to show --Select-- as the default value using the CakePHP form helper,
I have a method public function show (text:Object=, title:String=, body=String=){ //blah } I want
Hi friends I have an editable text box with a default value like to
Is there a better way to write this code? I want to show a
This might not appear like a programming question, but inherently deals with code. I
iPhone resources by default show up in a Resources group that's visible in the
Is there any way to have a default MessageBox.Show() caption? Let says I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.