• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

How to work with pre defined array?

November 12, 2012 by Rick Hernandez Leave a Comment

The only difference in this peace of code is that instead of an array that has a fixed size, its an array that is pre defined size. What i mean to say in simple terms is that I have created 10 shelf’s to store my beautiful numbers, so shelf 0 stores 2 and shelf one stores 7, ….. so on till shelf 10 and that’s where 7 lives. So this type of arrays are great when you actually know the number of shelf’s and what will be stored inside of them.

public class Program
{
    public static void main(String args[]) 
    {
        // initialize list
        int [] array =  {2,7,4,8,5,4,0,0,0,7};
        System.out.printf("%s%8s\n", "Index", "Value");
        
        
        for (int c= 0; c < array.length; c++)
        {
            System.out.printf("%5d%8d\n", c, array[c]);
        }
        
    }
}
 
Rick Hernandez

I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: Java, Programming

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in