Compile Error in Enhanced For Loop

I'm learning generic collections and for practice wrote a simple class that uses a HashMap to store data. However, I'm getting a compile error for the code that accesses the HashMap. The error and code for my class follow.
Can anyone help?
Thanks...
=====================
The compile error:
=====================
MapDict.java:37: package Map does not exist for( Map.Entry entry : glossary.entrySet()  )                        ^1 error=======================
The code for my class:
=======================
import java.util.Scanner;
import java.util.HashMap;
public class MapDict
     HashMap<String, String> glossary = new HashMap<String, String>();
     public void getEntries()
          Scanner sc = new Scanner( System.in ).useDelimiter("\n");
          String moreEntries = "y";
          String word        = "";
          String definition  = "";
          while ( moreEntries.toUpperCase().equals( "Y") )
               System.out.print("Enter word: ");
               word = sc.next();
               System.out.print("Enter definition: ");
               definition = sc.next();
               glossary.put( word, definition);
               System.out.print("Another glossary item? (y/n) ");
               moreEntries = sc.next();
     public void displayEntries()
          System.out.println( glossary.size() );
          // Here is where the compile error occurs:
          for( Map.Entry entry : glossary.entrySet()  )
               System.out.println( "\nWord: " + entry.getKey() + " Definition: " + entry.getValue() );
}

import java.util.Scanner;
import java.util.HashMap;I don't see java.util.Map or java.util.Map.Entry listed here....

Similar Messages

  • BUG: 10.1.3..36.73 Internal Compile Error with enhanced for loop/generics

    I get the following compiler error when using the Java 5 SE enhanced for loop with a generic collection.
    Code:
    public static void main(String[] args)
    List<Integer> l = new ArrayList<Integer>();
    l.add(new Integer(1));
    printCollection(l);
    private static void printCollection(Collection<?> c)
    for (Object e : c)
    System.out.println(e);
    Error on attempting to build:
    "Error: Internal compilation error, terminated with a fatal exception"
    And the following from ojcInternalError.log:
    java.lang.NullPointerException
         at oracle.ojc.compiler.EnhancedForStatement.resolveAndCheck(Statement.java:2204)
         at oracle.ojc.compiler.StatementList.resolveAndCheck(Statement.java:4476)
         at oracle.ojc.compiler.MethodSymbol.resolveMethod(Symbol.java:10822)
         at oracle.ojc.compiler.RawClassSymbol.resolveMethodBodies(Symbol.java:6648)
         at oracle.ojc.compiler.Parser.resolveMethodBodies(Parser.java:8316)
         at oracle.ojc.compiler.Parser.parse(Parser.java:7823)
         at oracle.ojc.compiler.Compiler.main_internal(Compiler.java:978)
         at oracle.ojc.compiler.Compiler.main(Compiler.java:745)
         at oracle.jdeveloper.compiler.Ojc.translate(Ojc.java:1486)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildGraph(UnifiedBuildSystem.java:300)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildProjectFiles(UnifiedBuildSystem.java:515)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildAll(UnifiedBuildSystem.java:715)
         at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.run(UnifiedBuildSystem.java:893)

    Install the Service Update 1 patch for JDeveloper (using the help->check for updates), and let us know if this didn't solve the problem.

  • Question about "Enhanced for loop"

    public class NewLoopTest{
         public NewLoopTest(){
              int result=0;                      
              int[] a=new int[20];           
              for(int i=0;i<a.length;i++){
                   a=i++;
              for(int i:a){  
    System.out.println("i="+i+";"+"a["+i+"]="+a[i]+";result="+result+"+"+i+"="+(result+i));
                   result+=i;           
              System.out.println("-------------");
              result=0;
              for(int i=0;i<a.length;i++){
                   System.out.println("i="+i+";"+"a["+i+"]="+a[i]+";result="+result+"+"+i+"="+(result+i));
                   result+=i;
    This code counts sum of the elements of a array.
    At first I use the enhanced for loop and at second I use the traditional for.
    Enhanced for loop in sdk1.5 returns only even elements of array, am I right?

    Enhanced for loop in sdk1.5 returns only even
    elements of array, am I right?No. It covers them all.
    The i in the enhanced for loop is not the index. It's the element at the current index. You don't have access to the index in the new loop because you don't need it.
    for (int item : arr) {
        System.out.println(item);
    // is equivalent to
    for (int ix = 0; ix < arr.length; ix++) {
        int item = aa[ix];
        System.out.println(item);
    }The i in your new loop is the same as a [ i ] in the old loop.

  • Enhanced for-loop by java5 needs to be more  enhanced?

    Hi, all of you,
    I often need to iterate a collection. Sometimes I need to iterate a subset of a collection. Then I have found the enhanced for-loop is not enough.
    Before Java 5, you did the following:
    for(int i=0;i<collection.size();i++) {
    Object object = collection.get(i);
    doSomething(object);
    }Thanks to Java 5, you can do the following:
    for(Object object:collection) {
    doSomething(object);
    }However, before Java 5, I have the flexibility to skip the first two lines by purpose, as follows
    for(int i=2;i<collection.size();i++) {
    Object object = collection.get(i);
    doSomething(object);
    }What should I do the same thing with Java 5?
    Kind regards.
    Pengyou

    pengyou wrote:
    JoachimSauer wrote:
    masijade. wrote:
    uncle_alice wrote:
    Or, if the collection is a List: for (Object obj : theList.subList(2, theList.size())) {
    doSomething(obj);
    Ah, yeah, I keep forgetting about that. ;-)
    Actually, I just never think about it. ;-)I think you're not alone. I find that subList() is severly under-used. It simplifies a lot of operations (ever tried someList.subList(0, someIndex).clear()? Try it).The solution is nice except it might throw IndexOutOfBoundsException.Which probably means a bug somewhere else. The way to avoid runtime exceptions is to write code that doesn't put you into situations where they'll arise, not to avoid them being thrown

  • How to get count from new enhanced for loop

    Is there a better way to determine the count when new enhanced for loop is used as follows:
    String[] test = new String[]{"1","2","3"};
    int count = 0;
    for(String i: test)
    count++;
    system.out.println("count: "+count);
    }

    There are cases where I need to use the count inside
    the for loop. I can keep track of the count by using
    the increment. But, then I would rather using the old
    for loop. Go ahead and use it. Are you under the assumption that the old form should be avoided?
    There is no saving in term of efficiency and readability.If there is any added efficiency in the "for each" form of the loop, it is on the micro level, and you would never notice it.
    As far as readability, look at some of the crazy solutions you've been given to avoid the general for loop, then reconsider which is more readable.

  • How do I use an enhanced for loop / for each on my ViewObjectImpl ?

    Guys and Gals,
    With all of my newly acquired Java knowledge in tow, I spent this weekend cleaning up all of my code, dealing mainly with for loops. I converted them from a huge mess to a for each type loop using language such as ...
        RowSet priceUpdateRows = (RowSet)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
        for (Row priceUpdateRow: priceUpdateRows)
        { // do operations on row... which makes perfect sense to me. For each Row in the RowSet, do something. It doesn't, however, makes sense to the compiler. It pouts and gives me a "foreach not applicable to expression type" error. So I read up on iterators and such, messed with code examples, and still can't get the RowSet to iterate with the above code. Could I make RowSet implement Iterable? How would I do that? I tried to create a class called RowSetExt which extended RowSet and implemented Iterable, but then I got a class cast exception.
    I know I could implement something like the following or a while(hasNext()) but they're really not what I'm looking for.
    ViewObject vo = … < Get ViewObject > …
    RowSetIterator rsi = vo.createRowSetIterator("rowsRSI");
    while (rsi.hasNext())
         Row row = rsi.next();
         row.setAttribute("YourAttribute",your_value);
         rsi.closeRowSetIterator();How do I make the for(Row row : <RowSet>) example work? Or could someone point me in a direction?
    Will

    One thing I tried was to make a framework extension class for my ViewObjectImpls
    public class PcsViewObjectImpl
      extends ViewObjectImpl
      implements Iterable<Row>
      Set<Row> set = new HashSet<Row>();
      public Iterator<Row> getRows()
        return set.iterator();
      public Iterator<Row> iterator()
        return getRows();
    }AppModuleImpl
        PriceUpdateRowsViewRowImpl priceUpdateRows = (PriceUpdateRowsViewRowImpl)((PriceUpdatesViewRowImpl) priceUpdate).getPriceUpdateRowsView();
        for (Row priceUpdateRow: priceUpdateRows)
        {However, this gives me a class cast exception at runtime. But I would think some kind of extension class would be the way to go ... ?

  • Compiled Error in Xcode for iphone game and other questions

    Dear all,
    Hi, I am a newbie of xcode and objective-c and I have a few questions regarding to the code sample of a game attached below. It is written in objective C, Xcode for iphone4 simulator. It is part of the code of 'ball bounce against brick" game. Instead of creating the image by IB, the code supposes to create (programmatically) 5 X 4 bricks using 4 different kinds of bricks pictures (bricktype1.png...). I have the bricks defined in .h file properly and method written in .m.
    My questions are for the following code:
    - (void)initializeBricks
    brickTypes[0] = @"bricktype1.png";
    brickTypes[1] = @"bricktype2.png";
    brickTypes[2] = @"bricktype3.png";
    brickTypes[3] = @"bricktype4.png";
    int count = 0;`
    for (int y = 0; y < BRICKS_HEIGHT; y++)
    for (int x = 0; x < BRICKS_WIDTH; x++)
    - Line1 UIImage *image = [ImageCache loadImage:brickTypes[count++ % 4]];
    - Line2 bricks[x][y] = [[[UIImageView alloc] initWithImage:image] autorelease];
    - Line3 CGRect newFrame = bricks[x][y].frame;
    - Line4 newFrame.origin = CGPointMake(x * 64, (y * 40) + 50);
    - Line5 bricks[x][y].frame = newFrame;
    - Line6 [self.view addSubview:bricks[x][y]]
    1) When it is compiled, error "ImageCache undeclared" in Line 1. But I have already added the png to the project. What is the problem and how to fix it? (If possible, please suggest code and explain what it does and where to put it.)
    2) How does the following in Line 1 work? Does it assign the element (name of .png) of brickType to image?
    brickTypes[count ++ % 4]
    For instance, returns one of the file name bricktype1.png to the image object? If true, what is the max value of "count", ends at 5? (as X increments 5 times for each Y). But then "count" will exceed the max 'index value' of brickTypes which is 3!
    3) In Line2, does the image object which is being allocated has a name and linked with the .png already at this line *before* it is assigned to brick[x][y]?
    4) What do Line3 and Line5 do? Why newFrame on left in line3 but appears on right in Line5?
    5) What does Line 4 do?
    Thanks
    North

    Hi North -
    macbie wrote:
    1) When it is compiled, error "ImageCache undeclared" in Line 1. ...
    UIImage *image = [ImageCache loadImage:brickTypes[count++ % 4]]; // Line 1
    The compiler is telling you it doesn't know what ImageCache refers to. Is ImageCache the name of a custom class? In that case you may have omitted #import "ImageCache.h". Else if ImageCache refers to an instance of some class, where is that declaration made? I can't tell you how to code the missing piece(s) because I can't guess the answers to these questions.
    Btw, if the png file images were already the correct size, it looks like you could substitute this for Line 1:
    UIImage *image = [UIImage imageNamed:brickTypes[count++ % 4]]; // Line 1
    2) How does the following in Line 1 work? Does it assign the element (name of .png) of brickType to image?
    brickTypes[count ++ % 4]
    Though you don't show the declaration of brickTypes, it appears to be a "C" array of NSString object pointers. Thus brickTypes[0] is the first string, and brickTypes[3] is the last string.
    The expression (count++ % 4) does two things. Firstly, the trailing ++ operator means the variable 'count' will be incremented as soon as the current expression is evaluated. Thus 'count' is zero (its initial value) the first time through the inner loop, its value is one the second time, and two the third time. The following two code blocks do exactly the same thing::
    int index = 0;
    NSString *filename = brickTypes[index++];
    int index = 0;
    NSString *filename = brickTypes[index];
    index = index + 1;
    The percent sign is the "modulus operator" so x%4 means "x modulo 4", which evaluates to the remainder after x is divided by 4. If x starts at 0, and is incremented once everytime through a loop, we'll get the following sequence of values for x%4: 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...
    So repeated evaluation of (brickTypes[count++ % 4]) produces the sequence: @"bricktype1.png", @"bricktype2.png", @"bricktype3.png", @"bricktype4.png", @"bricktype1.png", @"bricktype2.png", @"bricktype3.png", @"bricktype4.png", @"bricktype1.png", @"bricktype2.png", ...
    3) In Line2, does the image object which is being allocated has a name and linked with the .png already at this line *before* it is assigned to brick[x][y]?
    Line 2 allocs an object of type UIImageView and specifies the data at 'image' as the picture to be displayed by the new object. Since we immediately assign the address of the new UIImageView object to an element of the 'bricks' array, that address isn't stored in any named variable.
    The new UIImageView object is not associated with the name of the png file from which its picture originated. In fact the UIImage object which inited the UIImageView object is also not associated with that png filename. In other words, once a UIImage object is initialized from the contents of an image file, it's not possible to obtain the name of that file from the UIImage object. Note when you add a png media object to a UIImageView object in IB, the filename of the png resource will be retained and used to identify the image view object. But AFAIK, unless you explicitly save it somewhere in your code, that filename will not be available at run time.
    4) What do Line3 and Line5 do? Why newFrame on left in line3 but appears on right in Line5?
    5) What does Line 4 do?
    In Line 2 we've set the current element of 'bricks' to the address of a new UIImageView object which will display one of the 4 brick types. By default, the frame of a UIImageView object is set to the size of the image which initialized it. So after Line 2, we know that frame.size for the current array element is correct (assuming the image size of the original png file was what we want to display, or assuming that the purpose of [ImageCache loadImage:...] is to adjust the png size).
    Then in Line 3, we set the rectangle named newFrame to the frame of the current array element, i.e. to the frame of the UIImageView object whose address is stored in the current array element. So now we have a rectangle whose size (width, height) is correct for the image to be displayed. But where will this rectangle be placed on the superview? The placement of this rectangle is determined by its origin.
    Line 4 computes the origin we want. Now we have a rectangle with both the correct size and the correct origin.
    Line 5 sets the frame of the new UIImageView object to the rectangle we constructed in Lines 3 and 4. When that object is then added to the superview in Line 6, it will display an image of the correct size at the correct position.
    - Ray

  • Error in cursor for loop

    Hi  Guys ,
    I am getting the below error in the following piece of code.I am using 11g.
           L_SQL_TXT:='begin'||CHR(32)||
          'for i in ( select '||l_col_list_1||', :in_tst_nm, :l_current_schema  from '||in_src_table||') LOOP
            insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||',TEST_NM , TEST_CREATED_BY);
          end LOOP;
          end;';
          dbms_output.put_line (l_sql_txt);
          EXECUTE IMMEDIATE l_sql_txt USING in_sav_nm,l_current_schema;
          dbms_output.put_line (SQL%ROWCOUNT || ' test records added');
           I am getting the below error
    Error report:
    ORA-06550: line 3, column 95:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 3, column 7:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    What am i doing wrong? Please suggest

    Raunaq wrote:
             insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||',TEST_NM , TEST_CREATED_BY);
    This insert statement doesn't look good! As you just passed TEST_NM and TEST_CREATED_BY as in a string. Those must have some values associated with!
    Like:- If those 2 are variables then it should be like :-
    -- For testing purpose with output !!!
    --- Added static values for references for the dynamic block
    Declare
    l_sql_txt varchar2(32767);
    get_test_schema varchar2(20) := 'scott';
    in_src_table varchar2(20) := 'src_tbl';
    l_col_list_1 varchar2(20) := 'col_name_1';
    l_col_list_2 varchar2(20) := 'col_name_2';
    test_nm varchar2(20) := 'Testing';
    test_created_by date :=sysdate ;
    begin
      l_sql_txt:='begin'||chr(32)||
          'for i in ( select '||l_col_list_1||', :in_tst_nm, :l_current_schema  from '||in_src_table||')
       loop
            insert into '||get_test_schema||'.'||in_src_table||' values('||l_col_list_2||','''||test_nm||''','''||test_created_by||''');
          end loop;
          end;';
       dbms_output.put_line ('sql text- '||l_sql_txt);
       --execute immediate l_sql_txt using in_sav_nm,l_current_schema;
          dbms_output.put_line (sql%rowcount || ' test records added');
    end;
    My OutPut looks like:-
    sql text- begin for i in ( select col_name_1, :in_tst_nm, :l_current_schema
    from src_tbl)
              loop
            insert into scott.src_tbl
    values(col_name_2,'Testing','04-JUL-13');
          end loop;
          end;
    test records added
    PL/SQL procedure successfully completed.

  • Having errors in basic for loop

    Folks
    I am tring to write SQL script that implements a block that contains a for-loop which increments a counter from 1 to 10 and inserts the counter value into the results field of the LOOPING table that i have created. i want to insert a null val in place of the counter if the counter value is equal to either 6 or 8.
    Below are my work
    Table creation
    CREATE TABLE LOOPING (Result VARCHAR2(60));
    I am expecting a output like this
    Result
    1
    2
    3
    4
    5
    NULL
    7
    Null
    9
    10
    My SCRIPT
    BEGIN
    FOR COUNTER IN 1..10
    IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
    THEN
    INSERT INTO MESSAGES
    VALUES(NULL);
    ELSE
    INSERT INTO MESSAGES
    VALUES(COUNTER);
    END LOOP;
    END;
    I am getting errors. I am a beginner . Please help me out .
    can you point out my errors and explain
    And finaly please tell me how to correct it .
    Thanks
    Guna

    1) When you get an error, it's always helpful to post the details of that error (the error number and the line number). That makes it far easier for us to help you.
    2) Thank you for posting your code and table definition. That definitely helps! In the future, you'll want to use the \ tag (6 characters, all lower case) before and after any code fragments to preserve the white space & indentation.  That makes your code far easier to read.
    3) Your code fails to compile because
    - you are missing the LOOP keyword between lines 2 and 3
    - you are missing the END IF at the end of your IF statement
    - you are referring to a table named MESSAGES while your CREATE TABLE statement refers to a table named LOOPING
    If you correct those three errors, your code will compile
    [code]
    SQL> ed
    Wrote file afiedt.buf
      1  BEGIN
      2    FOR COUNTER IN 1..10
      3    LOOP -- Added
      4      IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
      5      THEN
      6        INSERT INTO looping -- Changed table name
      7          VALUES(NULL);
      8      ELSE
      9        INSERT INTO looping -- Changed table name
    10          VALUES(COUNTER);
    11      END IF; -- Added
    12    END LOOP;
    13* END;
    SQL> /
    PL/SQL procedure successfully completed.
    [/code]
    4) However, now that the code compiles, you'll have a problem that it does not meet the requirements.  It will never insert a NULL value because your IF condition is incorrect.  Since this looks like a homework problem, however, I don't want to completely give it away-- I've probably done more than I should have already.
    Justin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Illegal start of type error when adding for loop to applet

    I have typed the following applet to print a horizontal row of stars with the length entered by the user (i.e. user enters 4 and applet prints out 4 stars in a row). Here is my code:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
           String input = "";
            int number;
         public void init()
              input = JOptionPane.showInputDialog ( null,
              "Enter a number\nbetween 1 and 30:" );
              number = Integer.parseInt( input );
         public void paint ( Graphics g )
              for ( int counter = 1; counter <= number; counter++ )
                                    System.out.print( "*" );
               System.out.println();
    };Now I am trying to make it do this 5 times, so it seems like just surrounding the init and paint methods in a for loop (i.e. for ( int i=1; i <= 5; i++ ) ) would do the trick but when I do that I get an illegal start of type error when trying to compile. Does anyone know why this error would show up. The most common reply to questions of this sort seems to be to check the closing braces but I have checked very carefully after adding the for loop and don't see any problems with mismatched braces. Could you please help me get on the right track as to how I can make this applet print a horizontal row of stars five times? All help is appreciated.

    Hello JTMOBOP:
    You were correct in figuring that I was trying to get the applet to print five rows of stars of different length according to five different inputs from the user. I tried your suggestions, and the code now does compile and run, but it still does not run properly (i.e. only asks user once for input and displays row of stars but does not show an input dialog again). Here is the code I have retyped:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
       String input = "";
       int[] number = new int[5];
       public void init()
          for ( int i = 0; i < 5; i++ )
             input = JOptionPane.showInputDialog ( null,
                "Enter a number\nbetween 1 and 30:" );
             number[i] = Integer.parseInt( input );
       public void paint ( Graphics g )
          for ( int i = 0; i < 5; i++ )
             for ( int myNumber = 0; myNumber <= number; myNumber++ )
    System.out.print( "*" );
    System.out.println();
    Any ideas what's going on here?
    Also, your comments about not being able to loop a method make sense. Thank you for the input so far.

  • Error CreateImage in for loop array

    Hi,
    I would like to dynamically create images inside a for loop. It dependent on the array_size that the sevlets will send. Snapshots of code:
    for (int i = 0; i < ARRAY_SIZE; i++)
    img[i] = Image.createImage("\"/nike" + (i+1) + ".png\"");
    }Error:
    java.io.IOException
         at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
         at javax.microedition.lcdui.ImmutableImage.<init>(+20)
         at javax.microedition.lcdui.Image.createImage(+8)
         at SlidesCanvas.createImages(+138)
         at SlidesCanvas.<init>(+146)
         at ListSlides.commandAction(+113)
         at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
         at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
         at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
         at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
    Is this a known bug in CreateImage? Or am i doing it in a wrong way?

    Herlena
    I tried this, it works.
    for (int i = 0; i < ARRAY_SIZE; i++) {
        img[i] = img.createImage("nike" + (i+1) + ".png");
    Hope your problem is solved, Darryl

  • Incompatible types error on a for loop

    Hi. I am in the middle of making a program and a decided to make a print statment to check to make sure everything was organized as it should be and I got an incompatible types error for the line where I start my for loop - for (index = 0 ...) etc. Since everything is an int, I'm not sure how they're not compatible with each other.. thoughts? here's my code so far, thanks
    import java.io.*; // needed for stream readers
    import java.lang.*;
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
    String      records;
    String      room_nbr_input;
    String      test_score_input;
    String      student_id;
    int          room_nbr_nbr;
    int          test_score_nbr;
    int          index;
    String[] record = new String[3];
    int[]     room_nbr = new int[30];
    int[]      test_score = new int[30];
    int[]     kount = new int[30];
         // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
              for (index = 0; index = room_nbr.length; index++)
                   System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

    thank you. here's the code.
    import java.io.*;       // needed for stream readers
    import java.lang.*;   
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
            String      records;
            String      room_nbr_input;
            String      test_score_input;
            String      student_id;
            int             room_nbr_nbr;
            int             test_score_nbr;
            int          index;
            String[] record = new String[3];
            int[]      room_nbr = new int[30];
            int[]       test_score = new int[30];
            int[]      kount = new int[30];
              // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
               for (index = 0; index = room_nbr.length; index++)
                    System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

  • Effectv don't compile. error: conflicting types for 'trunc'

    hello all.
    i'm full newbie, so please, be kind
    I try to install effectv from AUR, but when i try to 'make' - i receive error:
    error: conflicting types for 'trunc'
    then i download sources and try to compile them - and again receive this error.
    Please advice, what should i do to correct this error?
    Thank you and sorry for my english.

    Please contact the author of the PKGBUILD to have it changed in the AUR. This fixes your issues:
    PKGBUILD
    # Contributor: Luiz Ribeiro <luizribeiro>
    pkgname=effectv
    pkgver=0.3.11
    pkgrel=1
    pkgdesc="EffecTV is a real-time video effector. You can watch TV or video through amazing effectors."
    url="http://effectv.sourceforge.net/"
    depends=('sdl')
    makedepends=('nasm')
    conflicts=()
    license=
    install=
    source=('http://jaist.dl.sourceforge.net/sourceforge/effectv/effectv-0.3.11.tar.gz'
    'gcc.patch' 'timedist.patch')
    md5sums=('71570b71009df0f1ff53e31de6f50cee')
    build() {
    cd $startdir/src/$pkgname-$pkgver
    patch -Np0 < $startdir/src/gcc.patch || return 1
    patch -Np0 < $startdir/src/timedist.patch || return 1
    sed -i -e 's_/usr/local_/usr_g' config.mk
    make || return 1
    mkdir -p $startdir/pkg/usr/bin
    mkdir -p $startdir/pkg/usr/man/man1
    make install INSTALL=/bin/install -c DESTDIR=$startdir/pkg || return 1
    gcc.patch : fixes compile problem
    --- utils.c.orig 2006-02-14 15:06:17.000000000 +0100
    +++ utils.c 2006-08-30 22:47:19.514145536 +0200
    @@ -26,7 +26,7 @@
    * HSI color system utilities
    -static int trunc(double f)
    +static int trunc_color(double f)
    int i;
    @@ -44,9 +44,9 @@
    Gv=1+S*sin(H);
    Bv=1+S*sin(H+2*M_PI/3);
    T=255.999*I/2;
    - *r=trunc(Rv*T);
    - *g=trunc(Gv*T);
    - *b=trunc(Bv*T);
    + *r=trunc_color(Rv*T);
    + *g=trunc_color(Gv*T);
    + *b=trunc_color(Bv*T);
    timedist.patch : fixes bug
    This is a quick fix for bugs of effectv-0.3.11. TimeDistortion has a border
    crossing bug and a buffer uninitializing bug.
    Index: effects/timedist.c
    ===================================================================
    --- effects/timedist.c (revision 478)
    +++ effects/timedist.c (working copy)
    @@ -27,7 +27,16 @@
    static int plane;
    static int *warptime[2];
    static int warptimeFrame;
    +static int bgIsSet;
    +static int setBackground(RGB32 *src)
    +{
    + image_bgset_y(src);
    + bgIsSet = 1;
    +
    + return 0;
    +}
    +
    effect *timeDistortionRegister(void)
    effect *entry;
    @@ -70,6 +79,7 @@
    plane = 0;
    image_set_threshold_y(MAGIC_THRESHOLD);
    + bgIsSet = 0;
    state = 1;
    return 0;
    @@ -94,6 +104,9 @@
    int *p, *q;
    memcpy(planetable[plane], src, PIXEL_SIZE * video_area);
    + if(!bgIsSet) {
    + setBackground(src);
    + }
    diff = image_bgsubtract_update_y(src);
    p = warptime[warptimeFrame ] + video_width + 1;
    @@ -109,7 +122,7 @@
    q += 2;
    - q = warptime[warptimeFrame ^ 1] + video_width + 1;
    + q = warptime[warptimeFrame ^ 1];
    for(i=0; i<video_area; i++) {
    if(*diff++) {
    *q = PLANES - 1;

  • Compilation error and method for inheritance

    1.I've tried to construct @create table for an entity.an error occurs which is:
    'Warning: Type Body created with compilation errors.'
    Why and how to solve it?
    2.as oracle 8 does not support inheritance,the other method would be through nested table.what else could it be?

    stop and start the siebel server will solve.
    Regards
    Ahmed

  • Enhance for loop question

    I like it, but I can't figure out how to use it for the following situation (printing contents of two arrays using one iterator):
    old way:
            System.out.println(menuTitle + "/n");
            for (int e ; e < length.menuChoices ; e++)
                System.out.print(menuChoices[e] + " - " + menuLabels[e]);
            }new?
            System.out.println(menuTitle + "/n");
            for (String e : menuChoices)
                System.out.print(e + " - " + menuLabels[????]);
            }Is there a nice way to do this or should I just use the old for loop and hope my teacher doesn't think that I just don't know about the new loop? Thanks.

    Is there a nice way to do this or should I just use
    the old for loop and hope my teacher doesn't think
    that I just don't know about the new loop?No there isn't. In the new for-loop the loop counter has been abstracted away. You'll have to either use the old for-loop, or introduce a counter in the new.
    Another way could be to change the design a little.
    class MenueItem {
       Type1 choice();
       Type2 label();
    for (String e : menuItems)  { // all MenuItems
       System.out.print(e.choise() + " - " + e.label());
    }

Maybe you are looking for

  • How to debug a RFC function module remotely from another R/3 system?

    Hi experts,    I have RFC function module in one R/3 system. I am calling this from another R/3 system that is cross apps (Xapps).    This function module is Synchronous.   Is it possible to debug this function module from cross apps?   Can somebody

  • Adding CD music to itunes...I have a problem!

    Why is it when I add a new cd to my old MacbookPro (OS X 10.5.8) into itunes running 10.6.3 It copy the music and the artist info, song name, album name etc. no problem. Then take the same cd put it in my new Macbook Pro (OS X 10.8.4) with itunes 11.

  • Replace function in JDeveloper 3.2

    Hi JDev Team: Are there any global replace functions in JDev 3.2, for instance I have one word, say 'aaaa', in all of my projct files, .jsp, .java, .... I like to replace with 'bbbb'. Thanks

  • CSS styles show in Safari, not Firefox

    If you go to http://www.noematiks.com on a Mac, the BOLD styles show in Safari but not in Firefox. Not sure about a Windows machine yet. The domain nameservers were changed about 32 hours ago and maybe propagation is causing this issue (thats what my

  • Resource Manager and Images

    Hi, I upgraded to RH9 (from RHX5) and very happily started to use both the Snippet and Resource Manager functionality. I seem to have hit a mental block despite reading the help and looking up this forum regarding updating images in the resource mana