<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Help with writing Arrays' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Help with writing Arrays' posted on the 'Java' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Mon, 17 Jun 2013 22:40:14 -0700</pubDate>
    <lastBuildDate>Mon, 17 Jun 2013 22:40:14 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Help with writing Arrays</title>
      <link>http://www.programmersheaven.com/mb/java/427911/427911/help-with-writing-arrays/</link>
      <description>Hi All,&lt;br /&gt;
&lt;br /&gt;
Is there a shorter way to achieve the following code, its a simple array table which is 3 rows by 4 columns.  Each number in the table is multiplied by 3 and then the max value position is given by identifying its position in the table, ie max_value is 33, its position is row 1, column 4&lt;br /&gt;
&lt;br /&gt;
Any help would be brilliant.&lt;br /&gt;
&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
public class page63&lt;br /&gt;
{&lt;br /&gt;
	public static void main(String []args)&lt;br /&gt;
	{&lt;br /&gt;
		Scanner myinput = new Scanner(System.in);&lt;br /&gt;
		int [][]  table =  {{0,1,11,3},{8,9,10,11},{4,5,6,1}};&lt;br /&gt;
		int i,j;&lt;br /&gt;
		int NO_OF_ROWS = 3;&lt;br /&gt;
		int NO_OF_COLS = 4;&lt;br /&gt;
		int max_val = table[0][0];&lt;br /&gt;
		int max_row_pos = 0;&lt;br /&gt;
		int max_col_pos = 0;&lt;br /&gt;
		&lt;br /&gt;
		for(i=0; i &amp;lt; NO_OF_ROWS; i++)&lt;br /&gt;
		{&lt;br /&gt;
			for(j=0; j &amp;lt; NO_OF_COLS; j++)&lt;br /&gt;
			{&lt;br /&gt;
				table[i][j] = table[i][j]*3;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		for(i=0; i &amp;lt; NO_OF_ROWS; i++)&lt;br /&gt;
		{&lt;br /&gt;
			for(j=0; j &amp;lt; NO_OF_COLS; j++)&lt;br /&gt;
			{&lt;br /&gt;
				System.out.print(table[i][j] + "\t"  );							&lt;br /&gt;
			}&lt;br /&gt;
			System.out.println();&lt;br /&gt;
		}                                                                                                               &lt;br /&gt;
		for(i=0; i &amp;lt; NO_OF_ROWS; i++)&lt;br /&gt;
		{&lt;br /&gt;
			for(j=0; j &amp;lt; NO_OF_COLS; j++)&lt;br /&gt;
			{&lt;br /&gt;
				if(table[i][j]&amp;gt;max_val)&lt;br /&gt;
				{&lt;br /&gt;
					max_val=table[i][j];&lt;br /&gt;
					max_row_pos=i+1;&lt;br /&gt;
					max_col_pos=j+1;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
				System.out.println(" ");&lt;br /&gt;
				System.out.println("Max value = "+max_val);&lt;br /&gt;
				System.out.println(" ");&lt;br /&gt;
				System.out.println("it's co-ordinates are row "+max_row_pos+" column "+max_col_pos);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/427911/427911/help-with-writing-arrays/</guid>
      <pubDate>Mon, 19 Mar 2012 04:43:44 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Help with writing Arrays</title>
      <link>http://www.programmersheaven.com/mb/java/427911/428028/re-help-with-writing-arrays/#428028</link>
      <description>Hi Helen,&lt;br /&gt;
&lt;br /&gt;
I don't know if you still need this, but anyway... you could do this without repeating all these for loops, like:&lt;br /&gt;
&lt;br /&gt;
public class page63 {&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) {&lt;br /&gt;
		int[][] table = { { 0, 1, 11, 3 }, { 8, 9, 10, 11 }, { 4, 5, 6, 1 } };&lt;br /&gt;
		int max_val = table[0][0];&lt;br /&gt;
		int max_row_pos = 0;&lt;br /&gt;
		int max_col_pos = 0;&lt;br /&gt;
&lt;br /&gt;
		for (int i = 0; i &amp;lt; table.length; i++) {&lt;br /&gt;
			for (int j = 0; j &amp;lt; table[i].length; j++) {&lt;br /&gt;
				table[i][j] = table[i][j] * 3;&lt;br /&gt;
				if (table[i][j] &amp;gt; max_val) {&lt;br /&gt;
					max_val = table[i][j];&lt;br /&gt;
					max_row_pos = i + 1;&lt;br /&gt;
					max_col_pos = j + 1;&lt;br /&gt;
				}&lt;br /&gt;
				System.out.print(table[i][j] + "\t");&lt;br /&gt;
			}&lt;br /&gt;
			System.out.println();&lt;br /&gt;
		}&lt;br /&gt;
		System.out.println("\nMax value = " + max_val);&lt;br /&gt;
		System.out.println("\nit's co-ordinates are row " + max_row_pos + " column " + max_col_pos);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/427911/428028/re-help-with-writing-arrays/#428028</guid>
      <pubDate>Wed, 28 Mar 2012 03:04:36 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Help with writing Arrays</title>
      <link>http://www.programmersheaven.com/mb/java/427911/428029/re-help-with-writing-arrays/#428029</link>
      <description>IGNORE - Duplicated by mistake</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/427911/428029/re-help-with-writing-arrays/#428029</guid>
      <pubDate>Wed, 28 Mar 2012 03:06:26 -0700</pubDate>
      <category>Java</category>
    </item>
  </channel>
</rss>