Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2007, 10:09 PM
Member
 
Join Date: Nov 2007
Posts: 19
jpnym15 is on a distinguished road
How do i
1.) Create a String array called Lester that has 76 Strings

2.) Create a double array called sue that holds 30 numbers, which are all 3.2

3.) Create an int array called jimmy that holds 12 ints and set them through the numbers 1 through 12, then sum them.

(sorry for all the questions, but i'm really new to this and these are practice exam questions)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-18-2007, 10:48 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
public class ArrayPractice { public static void main(String[] args) { // Create a String array called Lester that has 76 Strings String[] Lester = new String[76]; // All elements of this array are null. System.out.println("Lester[0] = " + Lester[0]); // Initialize the firs element. Lester[0] = "hello world"; System.out.println("Lester[0] = " + Lester[0]); // Create a double array called sue that holds 30 numbers, // which are all 3.2 double[] sue = new double[30]; // All elements are initialized to default zero value. System.out.println("sue[0] = " + sue[0]); // Initialize to requested initial value. for(int j = 0; j < sue.length; j++) sue[j] = 3.2; System.out.println("sue[12] = " + sue[12]); // Create an int array called jimmy that holds 12 ints // and set them through the numbers 1 through 12, then sum them. int[] jimmy = new int[12]; for(int j = 0; j < jimmy.length; j++) jimmy[j] = j+1; int total = 0; for(int j = 0; j < jimmy.length; j++) total += jimmy[j]; System.out.println("total = " + total); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 03:52 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org