Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# arrays

nick danasi
Greenhorn
Posts: 15
can anyone suggest we about these and these are to be done with just using arrays and neither with objects or packages??
1)In the given two dimensional array, find out the position of number 66 and print.

Input - int[][] a2 = {{5, 8, 9, 4},{11, 55, 66, 88}};

Output - 55 digit found at row - and column -???

2)Create a char array and add name 'VENKATESH PILLAI'.

Find out how many times character 'A' is repeating in the name and Position of character 'A'.

Output -

Character 'A' repeating 2 times

Position of 'A' is

Position of 'A' is

Steve Luke
Bartender
Posts: 4181
21
Hi dan,

Welcome to the Ranch! This looks like a homework question. Here at the Ranch we like to encourage you to DoYourOwnHomework (<- link). We can and still will help you out, but first, you should ShowSomeEffort - the work that you have done and are having trouble completing, and TellTheDetails - let us know exactly the parts you are struggling with.

So if you could please show us what you have done and where you are having trouble, it would help us help you out.

nick danasi
Greenhorn
Posts: 15
Steve Luke wrote:Hi dan,

Welcome to the Ranch! This looks like a homework question. Here at the Ranch we like to encourage you to DoYourOwnHomework (<- link). We can and still will help you out, but first, you should ShowSomeEffort - the work that you have done and are having trouble completing, and TellTheDetails - let us know exactly the parts you are struggling with.

So if you could please show us what you have done and where you are having trouble, it would help us help you out.

Hi steve , thanks for reply and its not homework question.
class d2{
public static void main(String [] args)
{
int i;
int j;
int [][] a = {{5,8,9,4},{11,55,66,88}};
System.out.print(" 55 digit found at row:");
for(i=1;i<a.length;++i)
{
for(j=1;j<a[i].length;j++)
{
System.out.print(a[i]);
}
System.out.print(a[j]);
}
}
}
this code i tried for array position and could suggest about the character i would do it myself.

nick danasi
Greenhorn
Posts: 15
Hi steve , thanks for reply and its not homework question.

this code i tried for array position and could suggest about the character i would do it myself.
i have the code for repeating char and there are no errors but i am not able to get an output to it

Tony Docherty
Bartender
Posts: 2958
59
thanks for reply and its not homework question.

If it's not your homework then why is it "really urgent"?

Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.

Tony Docherty
Bartender
Posts: 2958
59
Arrays in Java start at index 0 but your code starts at 1.
Can you explain what your code is supposed to do and how that relates to the question.

Actually, on second thoughts, ignore the above and follow the advice below:

I suggest you StopCoding (← click) right now and write out in your native language how you would solve this yourself. Write out every step in detail describes each action you would take then look at converting this to code.

nick danasi
Greenhorn
Posts: 15
the reason i said urgent and soon because i was trying for a long time.
i have another issue

public class Snippet
{
public static void main(String [] args){
String week[][] = {{"First","Monday"},{"Second","Tuesday"},{"Third","Wednesday"},{"Fourth","Thursday"},{"Fifth","Friday"},{"Sixth","Saturday"},{"Seventh","Sunday"}};
for(int i= 0;i< week.length;i++)
{
System.out.print(week[i][0]);
System.out.print( " day of the week " + " is: " );
for(int j= 1;j<week[0].length;j++)
{
System.out.println();
System.out.print(week[0][j]);
}
//System.out.print(week[0][j]);
System.out.println();
}
}
}
output is supposed to be first day of the week is monday till sunday but i am getting all days of the week as monday

Tony Docherty
Bartender
Posts: 2958
59
Please UseCodeTags when posting code as I have previously requested. Also please post the code you are running, this code won't compile. - Ninja edit

Tony Docherty
Bartender
Posts: 2958
59
Why do you have an inner for loop, there are only two elements in that array and you are ignoring the first element?

nick danasi
Greenhorn
Posts: 15

String week[][] = {{"First","Monday"},{"Second","Tuesday"},{"Third","Wednesday"},{"Fourth","Thursday"},{"Fifth","Friday"},{"Sixth","Saturday"},{"Seventh","Sunday"}};
for(int i= 0;i< week.length;i++)
System.out.print(week[i][0]);
System.out.print( " day of the week " + " is: " );
for(int j= 1;j<week[0].length;j++)
System.out.println();
System.out.print(week[0][j]);
System.out.println();

this is code which compiles

Tony Docherty
Bartender
Posts: 2958
59
What has happened to the curly braces?
And where are the code tags I keep suggesting you use. If you post unformatted code then it makes it very hard to read and if your code is hard to read then people won't bother and so you won't get any answers to your problem..