Results 1 to 3 of 3

Thread: Produce matrix of char and int

  1. #1
    EvansMitchell is offline Senior Member
    Join Date
    Dec 2009
    Posts
    227
    Rep Power
    3

    Default Produce matrix of char and int

    I would like to generate matrix containing integers and characters. Though in many examples I had seen matrices possess one type. So please provide me some suggestions to solve this problem.

  2. #2
    RogersNguyen is offline Senior Member
    Join Date
    Dec 2009
    Posts
    227
    Rep Power
    3

    Default

    Use Code given below to solve the problem:

    Public class Test {
    Public static void hand(String[] args) {
    int[][] a = {{1, 2, 3},{4, 'a', 6},{'a', 'b', 'c'}};
    for(int x =0; x <a.length; x + +)
    for(int y =0J <a[x].lengthJ + +)
    System.out.System.out.println(a[x][y]);
    }}

  3. #3
    MorganCooper is offline Senior Member
    Join Date
    Dec 2009
    Posts
    233
    Rep Power
    3

    Default

    See code given below which may help to solve your problem.

    Public class Test {
    Public static void hand(String[] args) {
    Object[][] a = {{new Integer(1), new Integer(2), new Integer(3)},{new Character('a'), new Character('b'), new Character('c')}};
    for(int i =0; I <a.length; I + +)
    for(int y =0J <a[i].lengthJ + +)
    System.out.System.out.println(a[i][y]);
    }}

Similar Threads

  1. Ink cartridge produce
    By SmithJohnson in forum other peripherals
    Replies: 1
    Last Post: 08-11-2010, 05:16 PM
  2. Function that accepts an integer/char array
    By ThompsonHarris in forum Programming
    Replies: 2
    Last Post: 07-08-2010, 01:50 PM
  3. Unable to produce Toolbar in Win XP
    By JacksonPerez in forum other peripherals
    Replies: 1
    Last Post: 05-14-2010, 01:20 PM
  4. Comparing char array in c++
    By BrooksGray in forum Programming
    Replies: 2
    Last Post: 02-16-2010, 05:41 PM
  5. GlobalFoundries will produce ARM
    By Theodosia Goodman in forum Latest Hardware News
    Replies: 0
    Last Post: 10-07-2009, 05:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48