Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java beginner

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java beginner

    Hi my interviewer said that if i can solve this problem he will get me a job he asked me: 'creates an integer array of size N, containing integers with values from 0 to N - 1, all different from eachother and prints them on the screen'

    so i have no idea what he was talking about but i tried to come up with a program like this but had 8 errors of being illegal star of expression needed ] etc.:
    public class recklesspk
    {
    public static void main(String[] args)
    {
     
    int a[N]; // This is the input
    int products_below[N];
    p=1;
    for(int i=0;i<N;++i)
    {
      products_below[i]=p;
      p*=a[i];
    }
     
    int products_above[N];
    p=1;
    for(int i=N-1;i>=0;--i)
    {
      products_above[i]=p;
      p*=a[i];
    }
     
    int products[N]; // This is the result
    for(int i=0;i<N;++i)
    {
      products[i]=products_below[i]*products_above[i];
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java beginner

    had 8 errors
    Please copy the full text of the error messages and paste them here.

    Please edit your post and properly format the code. Statements should be indented to show their logic nesting level and not all start in the first column.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java beginner

    I am a beginner to java as well, so thought this might be good practice for me. Here's my code
    <<<<<<<<<<<<<< code removed
    Last edited by Norm; January 9th, 2013 at 07:23 AM. Reason: removed spoonfed code

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java beginner

    Pleaase don't do the OPs work for him,
    http://www.javaprogrammingforums.com...n-feeding.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: January 6th, 2013, 06:32 AM
  2. Need Help - I am not even a beginner in Java :(
    By rrypo123 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 13th, 2012, 10:34 PM
  3. Im a java beginner and I need help :|
    By javaDO in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 8th, 2012, 03:28 PM
  4. JAVA Beginner needs help
    By rhaupert in forum Member Introductions
    Replies: 1
    Last Post: February 12th, 2012, 09:27 AM
  5. Java Beginner
    By kney in forum Java Theory & Questions
    Replies: 10
    Last Post: October 18th, 2011, 06:38 AM