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

  • Home
  • SEARCH
  • 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 7941047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:32:53+00:00 2026-06-03T23:32:53+00:00

I am not able to assign a String variable to a String Array. My

  • 0

I am not able to assign a String variable to a String Array.
My code is :

//Declaring a String array 
public String [] fileWrite = new String [10]; 

//assigning a variable 

String value = String.valueOf(aChar1);
fileWrite[0] = value;

But when I try to print the array, it gives null. I checked the value of variable value but that is ok. I cant understand the reason of array being null.

  • 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-03T23:32:55+00:00Added an answer on June 3, 2026 at 11:32 pm

    Firstly, you need to know that “printing an array” in java is somewhat “broken”: You need to use Arrays.toString(array) to print an array (you can’t rely on array.toString() – it isn’t useful).

    Try this code:

    public static void main(String[] args) {
        String[] fileWrite = new String[10];
        char aChar1 = 'x';
        String value = String.valueOf(aChar1);
        fileWrite[0] = value;
        System.out.println(Arrays.toString(fileWrite));
    }
    

    Output:

    [x, null, null, null, null, null, null, null, null, null]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not able to assign a generic list to ViewBag. Here is my code:
I am not able to figure out why it is not tracing value for
I'd really like to be able to assign a std::string object from a DecoratedString
I am running an asp.net code-behind that creates a string variable which holds a
Consider the following code: public class TextType { public TextType(String text) { underlyingString =
Im not able to load the page with circlepageindicator. This is the xml <FrameLayout
I am not able to flush stdin here, is there a way to flush
I am not able to make a clear decision on this one. I am
I am not able to get my jwysiwyg and Jhtmlarea text editors to work
I'm not able to connect a simple client and a simple server. When I

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.