- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Accessing multidimensional char array
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2011 12:58 AM
тАО03-31-2011 12:58 AM
Accessing multidimensional char array
I am facing problem in running the following code of multidimensional char array. The program is properly compiled but while running it provides a default output instead of characters matrix. Kindly help me in this.
class CharArray
{
public static void main(String ar[])
{
char ca=new char[2][2];
ca[0][0]='a';
ca[0][1]='b';
ca[1][0]='c';
ca[1][1]='d';
for(int i=0;i
for(int j=0;j
ca[i][j]=(char)i;
System.out.print(a[i][j]);
}
System.out.println("");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2011 11:07 PM
тАО04-01-2011 11:07 PM
Re: Accessing multidimensional char array
>ca[i][j]=(char)i;
Any reason you are putting control chars into your array?
You might want to print out "i" and "j" so you know you are going through your nested loops properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2011 11:29 PM
тАО04-04-2011 11:29 PM
Re: Accessing multidimensional char array
I couldnt understand ur question. I want to print matrix of characters(a,b,c,..). I am unable to do it as I m getting default symbols while I run the program. So I need ur help to get proper output, as I am unable to judge where exactly I am missing.
The same program I have made for number matrix and its running exactly as needed. Only for char I couldnt make it out.
Kindly help me in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2011 12:02 AM
тАО04-05-2011 12:02 AM
Re: Accessing multidimensional char array
What default symbols?
You should redirect the output to a file an get a hex dump on that file:
xd -tc -tx1 file
>Only for char I couldn't make it out.
As I said, you are putting control chars into the array, not the characters:
ca[i][j]=(char)i;
Leave this out if you want that initial "a" ... "d".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2011 12:10 AM
тАО04-05-2011 12:10 AM
Re: Accessing multidimensional char array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2011 06:22 PM
тАО04-05-2011 06:22 PM
Re: Accessing multidimensional char array
Only if you want a C source.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 12:00 AM
тАО04-06-2011 12:00 AM
Re: Accessing multidimensional char array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 03:19 AM
тАО04-06-2011 03:19 AM
Re: Accessing multidimensional char array
I can't help you there.
But as I said, try removing: ca[i][j]=(char)i;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 06:42 AM
тАО04-06-2011 06:42 AM
Re: Accessing multidimensional char array
class TwoDArray
{
public static void main(String ar[])
{
int[][] twod=new int[5][5];
for(int i=0;i
for(int j=0;j
twod[i][j]=i;
System.out.print(+twod[i][j]);
}
System.out.println("");
}
}
}
Output :-
00000
11111
22222
33333
44444
Kindly help me in coding similar program for displaying char matrix..
a b
c d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2011 09:41 PM
тАО04-06-2011 09:41 PM
Re: Accessing multidimensional char array
If you already have these initializers: ca[0][0]='a';
You don't need: ca[i][j]=(char)i;
In C you could do:
ca[i][j]=(char)(i*2 + j + 0x40);
Or even better, assuming ASCII:
ca[i][j]=(char)(i*2 + j + ('a' - 1));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-10-2011 10:55 PM
тАО04-10-2011 10:55 PM
Re: Accessing multidimensional char array
Kindly provide me the complete program for this.