aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes clear the doubt please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "clear the doubt please" Watch "clear the doubt please" New topic
Author

clear the doubt please

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
1)what will be the output?
char[] c = new char[100];

c[50]

2) why the output is 24 what happend to other ...
class S {


public static void main(String[] args) {
int[] dayhigh = { 24, 23, 24, 25, 25, 23,32 };

for(int i=0;i<dayhigh.length;i++)
{

System.out.println(dayhigh[0]);
}

}

}


24

24

24

24

24

24

24
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
why the output is 24 what happend to other ...
class S
{
public static void main(String[] args) {
int[] dayhigh = { 24, 23, 24, 25, 25, 23,32 };
for(int i=0;i<dayhigh.length;i++)
{
System.out.println(dayhigh[0]);
}
}
}

Hi Friend,

Length variable will give the Length of the Variable. In this case it is 7.
You are printing the value of daylight[0]. so it is printing value 24, 6th times.

If you give the Statement as
System.out.println(dayhigh[i]);
it will print all the 7 values.
[ April 27, 2005: Message edited by: deepak bhalotia ]
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
i am sorry i ovelooked the details
i am closing the topic
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
1)what will be the output?
char[] c = new char[100];

c[50]

Array gets initialized to their default values.Character's default value is space. So when you print c[50], nothing is displayed on the screen.

With Regards,
Deepak
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clear the doubt please
 
Similar Threads
Doubt in array's question
Cryptography
Implicit Widening aka Conversions ???
how to convert string into string array
The Game of Life - Please HELP!