-
Re: writing code for an array
"Keith Teo" <ksteo1@singnet.com.sg> wrote:
>
>"angel" <eneg@jps.net> wrote:
>>
>>with an array called "fraction" of type float, what would be the code needed
>>to assign the value 1.667 to array element9 and the value to array3.333
>to
>>array element 7.
>>
>>thank you
>
>Assuming you have an array named fraction of type float, so..
>float []fraction;
>And that you have a total of 9 elements in your array, so..
>fraction= new float[8];
>Remember, float[0] also counts as a element, java array starts indexing
from
>0.
>so to assign 1.667 to element 9.. u do this..
>fraction[8]=1.667;
>and to assign 3.333 to element 7.. u do this..
>fraction[6]=3.333
>
>so code fragment is actually as follows..
>
>float []fraction=new float[8];
>fraction[8]=1.667;
>fraction[6]=3.333;
>
>nb ls reply to my email if you need clarifications.
>
>
>
thanks so much for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks