Results 1 to 6 of 6
  1. #1
    bobbob is offline Member
    Join Date
    Oct 2016
    Posts
    2
    Rep Power
    0

    Default Massive values to console

    I want that all massive values to be printed to console.
    Of course I can initialize values this way: mas [0] = 10;
    But that would be very time consuming to set values for 100 massive elements.

    So what I want?
    First value is 10, second is 11, 3rd is 11, and so on every value grows by +1...





    Java Code:
    package DO;
    
    public class Araylay {
    
    	public static void main(String[] args) {
    		
    		int mas [] = new int [5];
    		
    		
    		int e = 0;
    		int b = 10;
    		
    		while ( e < 4) 		{
    		
    			e++;
    		    b++;
    			
    		System.out.println (  mas [e] + b );	}
    		
    	
    		
    		
    		
    		System.out.println ( mas [0] );
    		
    		
    	
    	}
    
    	
    	
    
    	
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Massive values to console

    What happens when you compile and execute the code?
    Post any output and add some comments saying what is wrong and show what you want the output to be.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Massive values to console

    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Massive values to console

    Quote Originally Posted by bobbob View Post
    So what I want?
    First value is 10, second is 11, 3rd is 11, and so on every value grows by +1...
    I am assuming you want to start with 10 and then increase each subsequent value by 1. I would use a for loop, starting with j = 0 and
    add j + 10 to each array value.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Massive values to console

    Check the other site. The OP has gotten lots of advice there.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    bobbob is offline Member
    Join Date
    Oct 2016
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Help with a massive problem
    By jolt in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 07:51 PM
  2. Massive Hit Deletion Help please
    By quickfingers in forum Java 2D
    Replies: 1
    Last Post: 12-24-2007, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •