Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: returning 2d array in java

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default returning 2d array in java

    public class test {
    	private String key;
    	private String plain;
    	String [][] plainArray = new String[4][4];
     
    	public String[][] getPlainArray(String plain)
    	{
     
    		int begin=0,end=2;
    		for(int i=0;i<=3;i++){
    			for(int j=0;j<=3;j++)
    			{
    				plainArray[i][j]=plain.substring(begin,end);
    				begin = begin+2;
    				end=end+2;
    			}
    		}
    		return plainArray;
    	}
     
     
    	public static void main(String arg[])
    	{
    		String plain="0123456789ABCDEF0123456789ABCDEF";
    		String key=  "d2f60c436e7ccebb8eaceaf3f86c8bad";
    		test t = new test();
     
    		for(int i=0;i<=3;i++)
    		{
    			for(int j=0;j<=3;j++)
    			{
    				System.out.print(t.plainArray[i][j]);
    			}
    			System.out.println();
    		}
     
     
    	}//end of main
     
    }//end of class


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: returning 2d array in java

    ...did you have a question?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,163
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: returning 2d array in java

    Do you have a question about your code?

Similar Threads

  1. Having trouble returning the right out put.
    By byako in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 26th, 2011, 11:49 PM
  2. [SOLVED] Java Beginner: Help with methods and returning values (hailstone program)
    By alf in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 14th, 2010, 06:28 PM
  3. returning a 2D array
    By straw in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 11th, 2010, 04:30 AM
  4. throwing and returning
    By chronoz13 in forum Exceptions
    Replies: 6
    Last Post: October 25th, 2009, 12:00 AM
  5. Returning Random Strings from an Array
    By cfmonster in forum Collections and Generics
    Replies: 3
    Last Post: September 8th, 2009, 11:13 PM