Facing syntax error in this simple code snippet

select case
when to_number (to_char(sysdate,'mm')) < 7
then (to_number(to_char(sysdate,'yyyy')) - 1)
from dual
--while if in block works fine
declare
year number;
begin
year := to_number(to_char(sysdate,'yyyy'));
if (to_number(to_char(sysdate,'mm')) < 7) then
year := year - 1;
end if;
dbms_output.put_line('year = '|| year);
end;

You can have:
-- 1 case expression
-- 1.2 searched case expressions
-- 2 simple case statement
-- 2.1 searched case statement
In your case you need the first one(-- 1 case expression ), because you return an expression.
Indeed a simple case statement let you choose a sequence of PL/SQL statements to execute. This follows another syntax.
It's not always true this statements
In PL/SQL you would use "END CASE". For this reason I can quietly show you that I can even use 'case expression' in PL/SQL, without end case:
DECLARE
    subtype TTempWord is varchar2(20);         -- good notation :-)
    valToCompare constant tTempWord:='test';
    temp  tTempWord ;  
    temp2 tTempWord ;
    --- start locals-------     ;-)
    procedure Compare_Display  -- with no parameters just for this dummy test!
    is
    begin
      dbms_output.put_line('Word to compare:'||valToCompare); 
      dbms_output.put_line('temp:'||temp);
      dbms_output.put_line('temp2:'||nvl(temp2,'not assigned'));
      temp2:= case temp when valToCompare then 'identic ' else 'NOT identic' end ; -- I'm  not using *'END CASE'*
      dbms_output.put_line('    --- after the assignation --->');
      dbms_output.put_line('temp:'||temp);
      dbms_output.put_line('temp2:'||temp2);        
      dbms_output.new_line;dbms_output.new_line;
    end;
    --- end locals-------     ;-)
BEGIN
      temp:='testttt'; 
      Compare_Display ;
      temp:=valToCompare;
      temp2:='';
      Compare_Display ;
END;--output
Word to compare:test
temp:testttt
temp2:not assigned
    --- after the assignation --->
temp:testttt
temp2:NOT identic
Word to compare:test
temp:test
temp2:not assigned
    --- after the assignation --->
temp:test
temp2:identic
PS:for more explanations related to all the cases you could look for at http://tahiti.oracle.com/
Edited by: zep111 on Apr 28, 2011 11:25 AM

Similar Messages

  • What's wrong with this simple code?

    What's wrong with this simple code? Complier points out that
    1. a '{' is expected at line6;
    2. Statement expected at the line which PI is declared;
    3. Type expected at "System.out.println("Demostrating PI");"
    However, I can't figure out them. Please help. Thanks.
    Here is the code:
    import java.util.*;
    public class DebugTwo3
    // This class demonstrates some math methods
    public static void main(String args[])
              public static final double PI = 3.14159;
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);

    Change your code to this:
    import java.util.*;
    public class DebugTwo3
         public static final double PI = 3.14159;
         public static void main(String args[])
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);
    Klint

  • ABAP Syntax error in this code - Could anyone help?

    Hi,
    I have this code which runs fine in our non-unicode SAP system.
    REPORT  ECC5_OFFSETS.
    DATA: W_KONV TYPE KONV.
    DATA: TKOMK LIKE STANDARD TABLE OF KOMK
                     WITH KEY KEY_UC
                     INITIAL SIZE 2
                     WITH HEADER LINE.
    DATA: TKOMK2 type STANDARD TABLE OF KOMK
                     WITH KEY KEY_UC
                     INITIAL SIZE 2.
    * Get some test data
    SELECT SINGLE * INTO W_KONV FROM  KONV
           WHERE  KNUMV  = '0000000061'.
    MOVE-CORRESPONDING W_KONV TO TKOMK.
    APPEND TKOMK.
    tkomk2[] = TKOMK[].
    * Original non-Unicode compliant code
    DATA: LENGTH_KEY_TKOMK(3) TYPE P.
    FIELD-SYMBOLS: <TKOMK_KEY> like TKOMK2.
    DESCRIBE DISTANCE BETWEEN TKOMK-MANDT AND TKOMK-SUPOS
              INTO LENGTH_KEY_TKOMK
    * ( Original Unicode syntax fix! )
              IN BYTE MODE.
    * Copy all the fields between these two into TKOMK_KEY field-symbol.
    * ( In Unicode this assignment fails, causing short dump at read )
    ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>.
    * Read the current record.
    READ TABLE TKOMK2 WITH KEY <TKOMK_KEY>.
    But I get the following error message in our UNICODE complaint SAP system:
    <b>"<TKOMK_KEY>" cannot be a table, a reference, a string, or contain any of these objects.</b>     
    Does anyone know how I could get around this/suggest a solution?
    Thanks in advance!

    Hi,
    Sorry if I'm being unclear.
    My requirements are twofold:
    1)the line of code:
    ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>
    does not assign anything to the fields symbol <TKOMK_KEY>
    2)The read statement does not like the fields symbol <TKOMK_KEY> being used as a key.
    Both these bits of code worked in our 4.6b system but now in the ECC5 environemtn I get syntax errors.
    Let me know if you need anything else!

  • 1093 Syntax error in Adobe devnet code?

    Hi All,
    I'm new to AC3 so maybe I'm mistaken... but I've tried to follow the steps in this Adobe AC3 tutorial: http://www.adobe.com/devnet/flash/articles/creating_animation_as3.html
    ..very closely and I'm getting a 1093 syntax error for the code below. Does anyone have an idea what the problem is..and what the fix would be?
    The line in red is the one that is indicated in the error message. (It's a tutorial about making a code snippet for tweening.)
    Thanks much!
    import fl.transitions.*;
    import fl.transitions.easing.*;
    * This Tween sample shows a fade-in effect
    * by default. Change the prop, to, from, and duration
    * values to change the animation. You can add code
    * in the event handler functions to respond to animation
    * event timing.
    function onTweenProgress(event:TweenEvent):void
        // do something as the tween progresses...
    function onTweenEnd(event:TweenEvent):void
       // do something when the tween ends...
    var prop:String = “alpha”;
    var from:Number = 0;
    var to:Number = 1;
    var duration:Number = 1;
    var tween:Tween = new Tween(rect_mc, alpha, Strong.easeOut, from, to, duration, true);
    tween.addEventListener(TweenEvent.MOTION_CHANGE, onTweenProgress);
    tween.addEventListener(TweenEvent.MOTION_FINISH, onTweenEnd);

    It's the double quotes that your code is using on that line.  I am guessing you copied and pasted from somewhere.  Try retyping the double quotes using your keyboard

  • Why Syntax error in this query?

    Hi
    I have this simple query, but in run time I have a "sytax error in INSERT INTO". Why?
    Statement st = con.createStatement();
    st.executeUpdate("INSERT INTO TMail (From, Oggetto) VALUES ('" +
    from + "', '" + mex.getSubject() +
    "')");

    If it's not a problem with a reserved word, then you're probably generating an invalid query. You need to print your query out and see what the query is.
    Also, many many many SQL problems can be avoided (nad you'll have cleaner, faster code), if you use PreparedStatement instead of Statement. Statement is for amateurs...
    static final String SQL = "INSERT INTO TMail (From, Oggetto) VALUES (?, ?)";
    PreparedStatement ps = con.prepareStatement(SQL);
    ps.setString(1, from);
    ps.setString(2, mex.getSubject() );
    ps.executeUpdate();

  • Syntax errors in old C++ code

    The following code is from an old C++ program that worked under old versions of Windows
    int FAR PASCAL _export NewFrameNameDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
    but now generates syntax errors as follows
    Error 1067
    error C2061: syntax error : identifier 'NewFrameNameDlg'
    Error 1068
    error C2059: syntax error : ';'
    Error 1069
    error C2059: syntax error : 'type'
    Any idea why?

    This will not work correctly in 32-bit Windows (or 64-bit) The type of wParam *must* be WPARAM, the type of lParam *MUST* be LPARAM, and for a dialog handler the return type should be BOOL. The old _export keyword no longer exists, and is not needed in
    Win32. FAR is a macro with an empty body and its appearance in all places can be deleted. The quaint and confusing PASCAL keyword may still work, but it would be better to use the now-correct term CALLBACK. Since this is clearly antique Win16 code, there may
    be other problems dealing with size of integers. The types int, long, DWORD, UINT and others all represent 32-bit values. The return type for window handlers must have the return type LRESULT, and for dialog handlers, BOOL. All wParam and lParam types must
    be changed as I indicated. Note that for Win16, wParam was 16-bit and lParam 32-bit. For Win32, WPARAM, LPARAM and LRESULT are all 32-bit values, and for Win64 they are 64-bit values. Any place the code casts a pointer to an integer type, the code is inherently
    incorrect. You must use types like INT_PTR, UINT_PTR, DWORD_PTR and other _PTR-suffixed types for such casts; in Win32 these are pointer-sized integer types (32-bit) and in Win64 they are pointer-sized integer types (64-bit). Types like int, long, DWORD, etc.
    are 32-bit values in both Win32 and Win64. Converting code to run on Win32/64 from Win16 requires great caution, because the programming "standards" that were taught for Win16 did not plan on true platform portability, and programmers were taught
    terrible techniques such as declaring wParam as WORD and LPARAM as long. And casting pointers to ints and back. All of these techniques lead to disaster.

  • Syntax error while creating tax codes for sales n purchases

    Hi all,
    While creating the tax codes for sales and purchases, i got the below error:
    Report RB13A003 has a syntax error.
    What should be done?
    Thank you

    Hi,
    I believe, it's RV13A003 report and not RB13A003... What is the exact error message (or is it a dump)?
    Regards,
    Eli

  • Facing syntax error while calling stored procedure

    hi
    iam calling a stored procedure which is a sybase USP.my code is as follows
    clsm3=CommonLib.cnClient.prepareCall("{call SYB1103.SIFGSYS..USP_Ins_ShipmentInvLines_Tmp "+coid+",'"+invclass+"',"+newsysno+","+productcd+",'"+batchno+"',"+qty+","+productrate+","+assrate+","+expercent+","+examt+","+saleed+","+bonused+",'"+recby+"',"+linestat+","+brno+","+prinvno+","+invno+","+recno+"}");
    clsm3.executeUpdate();
    where clsm3 is an object of CallableStatement.but it is giving me a syntax error saying
    "Invalid JDBC escape syntax at line position 84 '}' character expected"
    please reply as soon as possible

    clsm3=CommonLib.cnClient.prepareCall("{call
    {call SYB1103.SIFGSYS..USP_Ins_ShipmentInvLines_Tmp
    "+coid+",'"+invclass+"',"+newsysno+","+productcd+",'"+
    batchno+"',"+qty+","+productrate+","+assrate+","+exper
    cent+","+examt+","+saleed+","+bonused+",'"+recby+"',"+
    linestat+","+brno+","+prinvno+","+invno+","+recno+"}")
    ;clsm3=CommonLib.cnClient.prepareCall("call <PROCEDURE_NAME>(?,?,?,....)
    clsm3.setString(1,coid);
    clsm3.setInt(2,invclass);
    and so on...
    Try the above. The syntax of the call is wrong in your code.

  • How to invoke jdb for this simple code

    up to now i have been debugging by looking at the code, could someone please tell me how
    to invoke jdb for the following example, and how would i look at the local values within x & y
    (without having to rely on JOptionPane):
    //pg73 ex2.16 The x value input must be larger than the y value
    import javax.swing.JOptionPane;
    public class ex2_11
    public static void main(String args[])
    int x =2, y=3;
    JOptionPane.showMessageDialog( null,
    "a x= " x            "\n " +
    "b the value of x+x is " + (x+x) + "\n " +
    "c x= " + "\n " +
    "d " + (x+y) + "= " + (y+x),
    "Results",JOptionPane.PLAIN_MESSAGE);
    System.exit(0);

    I think I have already answered this question somewhere else, but I will reiterate it here.
    If you have compile errors in your source code (i.e. you left the semi-colon off at the end of a statement), a class file will not get generated.
    What you have done is the following:
    1. created a working java source file
    2. compiled that file and generated a class file
    3. then changed the working source file and introduced a compiler error (i.e. you left the semi-colon off at the end of a statement)
    4. then attempted to compile the file (with javac), but due to the compiler error a new class file did not get generated (therefore the old class file from the previous compile still resides on your machine).
    5. Then you ran jdb on the old previously generated class file.
    To confirm what I am saying is true. Delete the class file, then try to generate it again after introducing your compiler error. A new class file will not get generated and therefore you won't be able to use jdb (as jdb requires the class files).
    Hope this helps (and gets me the duke dollars),
    Tim

  • Rounding errors when plotting rectangles (simple code snippet included)

    hi,
    I'm having a problem with rounding errors, and am unsure what the best thing to do is..
    If you run the snippet of code below, you'll see some rectangles with black lines between them. The range of values covered in the model behind the plot is contiguous, and its only after scaling the trouble begins..
    does anyone have suggestions for what to do here? I need this resize behaviour.. I'm unable to change the interval class :)
    thanks,
    asjf
    import java.awt.Color;
    import java.awt.Graphics;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    @SuppressWarnings("serial")
    public class RoundingError extends JPanel {
         List<Interval> intervals;
         private static final int WIDTH= 25000000;
         private static final int INC= 1000000;
         public RoundingError() {
              setBackground(Color.BLACK);
              intervals= new ArrayList<Interval>();
              for(int i=0; i<WIDTH; i+=INC) {
                   intervals.add(new Interval(i, i+INC));
         @Override
         protected void paintComponent(Graphics g) {
              super.paintComponent(g);
              double scale= getWidth()/(double)WIDTH;
              for(Interval i : intervals) {
                   Random r= new Random(System.identityHashCode(i));
                   g.setColor(new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)));
                   int sx= (int) (i.start * scale);
                   int sy= getHeight()>>2;
                   int sw= (int) ((i.end-i.start) * scale);
                   int sh= getHeight()>>1;
                   g.fillRect(sx,sy,sw,sh);
         public static void main(String[] args) {
              JFrame frame= new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new RoundingError());
              frame.setSize(800,600);
              frame.setVisible(true);
    class Interval {
         final int start, end;
          * @param start inclusive bound
          * @param end exclusive bound
         Interval(int start, int end) {
              this.start= start;
              this.end= end;
    }

    import java.awt.Color;
    import java.awt.Graphics;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    @SuppressWarnings("serial")
    public class RoundingError extends JPanel {
        List<Interval> intervals;
        private static final int WIDTH= 25000000;
        private static final int INC= 1000000;
        boolean firstTime = true;
        public RoundingError() {
            setBackground(Color.BLACK);
            intervals= new ArrayList<Interval>();
            for(int i=0; i<WIDTH; i+=INC) {
                intervals.add(new Interval(i, i+INC));
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            double scale= getWidth()/(double)WIDTH;
            int count = 0;
            int errorX = 0;
            int totalW = 0;
            int lastX = 0;
            int[] errors = new int[intervals.size()];
            for(Interval i : intervals) {
                Random r= new Random(System.identityHashCode(i));
                g.setColor(new Color(r.nextInt(256),
                                     r.nextInt(256), r.nextInt(256)));
                int sx= (int) (i.start * scale);
                int sy= getHeight()>>2;
                int sw= (int) ((i.end-i.start) * scale);
                int sh= getHeight()>>1;
                if(firstTime) {
                    totalW += sw;
                    if(count > 0) {
                        int error = sx - lastX;
                        if(error != 0) {
                            errors[count] = error;
                        errorX += error;
                    lastX = sx + sw;
                    System.out.printf("count = %2d  sx = %3d  sy = %3d  " +
                                      "sw = %3d  dh = %3d  totalW = %d%n",
                                       count++, sx, sy, sw, sh, totalW);
                g.fillRect(sx,sy,sw,sh);
            if(firstTime) {
                System.out.printf("errorX = %d%n" +
                                  "lastX - totalW = %d%n",
                                   errorX, lastX - totalW);
                for(int i = 0; i < errors.length; i++) {
                    if(errors[i] != 0) {
                        System.out.printf("errors[%2d] = %d%n", i, errors);
    firstTime = false;
    public static void main(String[] args) {
    JFrame frame= new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new RoundingError());
    frame.setSize(800,600);
    frame.setVisible(true);
    class Interval {
    final int start, end;
    * @param start inclusive bound
    * @param end exclusive bound
    Interval(int start, int end) {
    this.start= start;
    this.end= end;
    This seems to work okay.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    @SuppressWarnings("serial")
    public class RoundingErrorRx extends JPanel {
        List<Interval> intervals;
        private static final int WIDTH= 25000000;
        private static final int INC= 1000000;
        boolean firstTime = true;
        public RoundingErrorRx() {
            setBackground(Color.BLACK);
            intervals= new ArrayList<Interval>();
            for(int i=0; i<WIDTH; i+=INC) {
                intervals.add(new Interval(i, i+INC));
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            double scale= getWidth()/(double)WIDTH;
            int count = 0;
            double errorX = 0;
            double totalW = 0;
            double lastX = 0;
            double[] errors = new double[intervals.size()];
            for(Interval i : intervals) {
                Random r= new Random(System.identityHashCode(i));
                g.setColor(new Color(r.nextInt(256),
                                     r.nextInt(256), r.nextInt(256)));
                double sx= i.start * scale;
                double sy= getHeight()>>2;
                double sw= (i.end-i.start) * scale;
                double sh= getHeight()>>1;
                if(firstTime) {
                    totalW += sw;
                    if(count > 0) {
                        double error = sx - lastX;
                        if(error != 0) {
                            errors[count] = error;
                        errorX += error;
                    lastX = sx + sw;
                    System.out.printf("count = %2d  sx = %5.1f  sy = %5.1f  " +
                                      "sw = %5.1f  dh = %5.1f  totalW = %5.1f%n",
                                       count++, sx, sy, sw, sh, totalW);
                g2.fill(new java.awt.geom.Rectangle2D.Double(sx,sy,sw,sh));
            if(firstTime) {
                System.out.printf("errorX = %5.1f  lastX - totalW = %5.1f%n",
                                   errorX, lastX - totalW);
                for(int i = 0; i < errors.length; i++) {
                    if(errors[i] != 0) {
                        System.out.printf("errors[%2d] = %5.1f%n", i, errors);
    firstTime = false;
    public static void main(String[] args) {
    JFrame frame= new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new RoundingErrorRx());
    frame.setSize(800,600);
    frame.setVisible(true);
    class Interval {
    final int start, end;
    * @param start inclusive bound
    * @param end exclusive bound
    Interval(int start, int end) {
    this.start= start;
    this.end= end;

  • Error in RMI simple code!

    i am using 4 files for rmi
    //Interface file
    public interface Calculator extends java.rmi.Remote{
    public long add(long a,long b)throws java.rmi.RemoteException;
    public long sub(long a,long b)throws java.rmi.RemoteException;
    public long mul(long a,long b)throws java.rmi.RemoteException;
    public long div(long a,long b)throws java.rmi.RemoteException;
    //Implementation file
    public class CalculatorImpl extends java.rmi.server.UnicastRemoteObject
    implements Calculator{
    public CalculatorImpl() throws java.rmi.RemoteException
    super();
    public long add(long a, long b) throws RemoteException {
    return(a+b);
    public long sub(long a, long b) throws RemoteException {
    return(a-b);
    public long mul(long a, long b) throws RemoteException {
    return(a*b);
    public long div(long a, long b) throws RemoteException {
    return(a/b);
    //Server File
    import java.rmi.Naming;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Vedita
    public class CalculatorServer {
    public CalculatorServer(){
    try{
    Calculator c = (Calculator) new CalculatorImpl();
    Naming.rebind("rmi://localhost:1099/Calculator", c);
    catch (Exception e) {
    System.out.println("Trouble"+e);
    public static void main(String args[]){
    new CalculatorServer();
    //Client File
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Vedita
    public class CalculatorClient {
    public static void main(String args[]) throws NotBoundException, MalformedURLException, RemoteException{
    try{
    Calculator c= (Calculator) Naming.lookup("rmi://remotehost:1099/Calculator");
    System.out.println(c.sub(4, 3));
    System.out.println(c.add(4, 5));
    System.out.println(c.mul(3, 6));
    System.out.println(c.div(9, 3));
    catch(MalformedURLException murle){
    System.out.println();
    System.out.println("MalformedURLException");
    System.out.println(murle);
    catch(RemoteException re){
    System.out.println();
    System.out.println("RemoteException");
    System.out.println(re);
    catch(NotBoundException nbe){
    System.out.println();
    System.out.println("NotBoundException");
    System.out.println(nbe);
    catch(java.lang.ArithmeticException ae){
    System.out.println();
    System.out.println("ArithmeticException");
    System.out.println(ae);
    i am executing the code as follows in command prompt
    in one cmd prompt
    javac *.java
    rmic CalculatorImpl
    rmiregistry
    in other cmd prompt
    javac *.java
    java CalculatorServer
    i am getting this error
    Error java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: CalculatorImpl_Stub
    Please Please help me because i have to submit the project in my college and this basic program is also not working in my pc. Please can anyone help me?

    //Implementation file
    public class CalculatorImpl extends java.rmi.server.UnicastRemoteObject
    implements Calculator{
    public CalculatorImpl() throws java.rmi.RemoteException
    super();super(0);

  • Plz help me in this simple code

    hi every one
    I try to generate a serial number the column ia varchar2
    I need to know the maxium length for the data in this column
    I try to write this code
    declare
    max_l number;
    begin
         select max(length(ITEM_NO)) into max_l from COMPANY_ITEMS;
    end if;
    this code give me value in toad but in form give me error
    how can I over comee at this error

    Hi,
    declare
    max_l number;
    begin
         select max(length(ITEM_NO)) into max_l from COMPANY_ITEMS;
    end if;The problem in your code is that you are using *"end if;"* instead of *"end;"*
    this code give me value in toad but in form give me error Not sure how it worked in toad, it will never work even in toad.
    Hope this helps.
    Best Regards
    Arif Khadas

  • What can be the error in this simple Linked List Implementation

    i have a linked list code that wont compile successfully. The code is
    //Lets try the Linked List 
    import java.util.*;
    class LinkedListDemo {
    public static void main ( String args[]){
         LinkedList l1=new LinkedList();
         l1.add( "A");
         l1.add(2);
         l1.add(3);
         l1.add(4);
         l1.add(5);
         l1.addFirst(6);
         l1.add(7);
         l1.add(8);
         l1.add(9);
         //Lets check what does the Linked List hold at this time
         System.out.println("Prsently the linked lis is having:  "+l1);
    }Problem is with the add method . Compiler error is that it doesnt recognize the symbol ie add method.

    i m sorry , java version is 1.4In that case, read up on the link jverd posted on AutoBoxing. You can only add Objects to a List. An int is a primitive, not an Object. You can try something like this:
    l1.add(new Integer(2));

  • Error compiling this example code of libcurl

    Its an example code to download a file and show gtk window..
    http://curl.haxx.se/libcurl/c/curlgtk.html
    I get this error:-
    shadyabhi@ArchLinux /tmp $ gcc curlgtk.c `pkg-config --libs --cflags libcurl`
    curlgtk.c:13:21: fatal error: gtk/gtk.h: No such file or directory
    compilation terminated.
    shadyabhi@ArchLinux /tmp $
    Then I tried :-
    shadyabhi@ArchLinux /tmp $ gcc curlgtk.c `pkg-config --libs --cflags libcurl` -I /usr/include/gtk-2.0/
    In file included from /usr/include/gtk-2.0/gdk/gdk.h:32:0,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from curlgtk.c:13:
    /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30:21: fatal error: gio/gio.h: No such file or directory
    compilation terminated.
    shadyabhi@ArchLinux /tmp $
    Whats the issue?
    The complete code:-
    /* Copyright (c) 2000 David Odin (aka DindinX) for MandrakeSoft */
    /* an attempt to use the curl library in concert with a gtk-threaded application */
    #include <stdio.h>
    #include <gtk/gtk.h>
    #include <curl/curl.h>
    #include <curl/types.h> /* new for v7 */
    #include <curl/easy.h> /* new for v7 */
    GtkWidget *Bar;
    size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
    return fwrite(ptr, size, nmemb, stream);
    size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
    return fread(ptr, size, nmemb, stream);
    int my_progress_func(GtkWidget *bar,
    double t, /* dltotal */
    double d, /* dlnow */
    double ultotal,
    double ulnow)
    /* printf("%d / %d (%g %%)\n", d, t, d*100.0/t);*/
    gdk_threads_enter();
    gtk_progress_set_value(GTK_PROGRESS(bar), d*100.0/t);
    gdk_threads_leave();
    return 0;
    void *my_thread(void *ptr)
    CURL *curl;
    CURLcode res;
    FILE *outfile;
    gchar *url = ptr;
    curl = curl_easy_init();
    if(curl)
    outfile = fopen("test.curl", "w");
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func);
    curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func);
    curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
    curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar);
    res = curl_easy_perform(curl);
    fclose(outfile);
    /* always cleanup */
    curl_easy_cleanup(curl);
    return NULL;
    int main(int argc, char **argv)
    GtkWidget *Window, *Frame, *Frame2;
    GtkAdjustment *adj;
    /* Must initialize libcurl before any threads are started */
    curl_global_init(CURL_GLOBAL_ALL);
    /* Init thread */
    g_thread_init(NULL);
    gtk_init(&argc, &argv);
    Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    Frame = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT);
    gtk_container_add(GTK_CONTAINER(Window), Frame);
    Frame2 = gtk_frame_new(NULL);
    gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN);
    gtk_container_add(GTK_CONTAINER(Frame), Frame2);
    gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5);
    adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
    Bar = gtk_progress_bar_new_with_adjustment(adj);
    gtk_container_add(GTK_CONTAINER(Frame2), Bar);
    gtk_widget_show_all(Window);
    if (!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0)
    g_warning("can't create the thread");
    gdk_threads_enter();
    gtk_main();
    gdk_threads_leave();
    return 0;

    Your error is unrelated to curl. You're not properly linking against gtk
    gcc curlgtk.c $(pkg-config --libs --cflags gtk+-2.0 libcurl)

  • Beginner Question | The use of modulus in this simple code example.

    Hello everyone,
    I am just beginning to learn Java and have started reading "Java Programming for the absolute beginner". It is quite a old book but seems to be doing the trick, mainly.
    There is a code example which I follow mostly but the use of the modulus operator in the switch condition doesn't make sense to me, why is it used? Could someone shed some light on this for me?
    import java.util.Random;
    public class FortuneTeller {
      public static void main(String args[]) {
        Random randini = new Random();
        int fortuneIndex;
        String day;
        String[] fortunes = { "The world is going to end :-(.",
          "You will have a HORRIBLE day!",
          "You will stub your toe.",
          "You will find a shiny new nickel.",
          "You will talk to someone who has bad breath.",
          "You will get a hug from someone you love.",
          "You will remember that day for the rest of your life!",
          "You will get an unexpected phone call.",
          "Nothing significant will happen.",
          "You will bump into someone you haven't seen in a while.",
          "You will be publicly humiliated.",
          "You will find forty dollars.",
          "The stars will appear in the sky.",
          "The proper authorities will discover your secret.",
          "You will be mistaken for a god by a small country.",
          "You will win the lottery!",
          "You will change your name to \"Bob\" and move to Alaska.",
          "You will discover first hand that Bigfoot is real.",
          "You will succeed at everything you do.",
          "You will learn something new.",
          "Your friends will treat you to lunch.",
          "You will meet someone famous.",
          "You will be very bored.",
          "You will hear your new favorite song.",
          "Tomorrow... is too difficult to predict" };
        System.out.println("\nYou have awakened the Great Randini...");
        fortuneIndex = randini.nextInt(fortunes.length);
        switch (randini.nextInt(7) % 7) {   
          case 0:
            day = "Sunday";
            break;
          case 1:
            day = "Monday";
            break;
          case 2:
            day = "Tuesday";
            break;
          case 3:
            day = "Wednesday";
            break;
          case 4:
            day = "Thursday";
            break;
          case 5:
            day = "Friday";
            break;
          case 6:
            day = "Saturday";
            break;
          default:
            day = "Tomorrow";
        System.out.println("I, the Great Randini, know all!");
        System.out.println("I see that on " + day);
        System.out.println("\n" + fortunes[fortuneIndex]);
        System.out.println("\nNow, I must sleep...");
    }

    randini.nextInt(7) % 7randini.nextInt(7) returns a value in the range 0 <= x < 7, right? (Check the API!) And:
    0 % 7 == 0
    1 % 7 == 1
    2 % 7 == 2
    3 % 7 == 3
    4 % 7 == 4
    5 % 7 == 5
    6 % 7 == 6Looks like superfluous code to me. Maybe originally they wrote:
    randini.nextInt() % 7Note this code has problems, because, for example -1 % 7 == -1

Maybe you are looking for

  • Media Encoder crash in CS6. Could not read from the source. Check if it has moved or been deleted.

    I'm having a problem getting Media Encoder to get past the dynamic link portion of encoding a time line sequence. I can send it over to Media Encoder, but it crashes consistently after the yellow bar saying something about dynamic link. I have CS6 in

  • Error 65016 when trying to open Dreamweaver

    When I try to open Dreamweaver, I get an error message that just says "65016" and the program crashes. I tried to reinstall using my original installation DVD's, but apparently the install application is no longer compatible with my current version o

  • How do I download adobe photoshop elements 12 without a cd drive

    I bought adobe Photoshop elements 12 and adobe premiere elements 12, but my laptop does not have a cd drive, how do i download it?

  • LIKOND01 IDoc

    Hello Experts, We have a requirement of sending listing data (whether articles is listed or delisted) from ECC to a legacy system. We have analyzed the option os using LIKOND01, Assortment 01or WBBDLD03. We opted for LIKOND01 since it is lighter as c

  • Incident creation loop

    Greetings. I've suffered a problem over my SCSM, i'll try to explain the scenario as good as I can. I got SCOM monitoring and resending critial alerts to SCSM as incidents, a few days ago, it detected a failed backup, so SCSM created an incident, and