import java.util.LinkedList;
import java.util.ListIterator;
import java.io.*;
public class llist {

    public static void main(String[] args) {
        String abc="poo";
        String[][] array_string;
        array_string= new String[10][10];
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){



error is:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    Cannot cast from int to String

    at llist.main(llist.java:14)

question is:
I want to display numbers in the string array(2D array)?

Edited by Reverend Jim: Fixed formatting

5 Years
Discussion Span
Last Post by pooran.c

Yes I think he means..
Integer.toString(int i)..

Or just write ""+i, this will create a String of the number, thats what I would do.


Yes, I know exactly what I meant. I deliberately gave the OP just enough info for him to look it up himself, thus getting essential practice in working the API JavaDoc. By giving him the actual code he can just copy/paste and learn nothing.

""+i is a judgement call. That's what I would do in my own code, but it's not helpful to just put it in front of a newbie without any explanation. I took the view that the explanation was likely to be confusing and unhelpful at this stage; and I certainly wasn't going to post it as some kind of magic formula.

It's always difficult to know how far to go in giving help or solutions.


I never said you didn't know what you meant, I just said I think I know what you meant.
Then I gave an alternative.
Cause I thought you may of meant, wrap the int into an Integer...
Integer xObj = new Integer(x);
Then, xObj.toString() [using toString() implementation from toString() in Object class].

So I think its wise to know about toString in Object class and how its implemented in subclasses as well as overloaded versions like the one you mentioned.

But as you gave a parameter, it must have been the static toString method that you meant, which is what I was trying to point out in my post


Hi @cms271828.
OK, I don't think we have any real disagreement here, and we shouldn't hijack the OPs thread anyway. I just wanted to encourage the OP top practice his API Javadoc skills.
It's cool.


ok guys i got what both were discussing in the post.
Thanks .

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.