Can't compile this code! can't tell why. Error message is below. Thanks

import java.util.*;
public class Library {
        private Collection books;                                               //Defining a collection of books here
        private Iterator bookIter;                                              //We want to iterate the collection of books here
        //Constructor to help us initialize our collection to hold elements of a newly created collection
        public Library() {
                books = new ArrayList();                                        //Our collection holds a the newly created collection of type ArrayList (providing storage for books)
                books.add(new Book("War and Crime"));
                books.add(new Book("The Redeemers"));
        public void display() {
                bookIter = books.iterator();
                while (bookIter.hasNext()) {
                        Book aBook = (Book)bookIter.next();
                        System.out.println("Title : " + aBook.ret_title());
        public static void main(String args[]) {
                display();
class Book {
        private String title;
        Book(String b_title) {
                this.title = b_title;
        public String ret_title() {
                return this.title;
}THIS IS THE ERROR:
"Library.java" 105 lines, 3597 characters
clio:~/javamachine/learning/topics/utils/Collection (Lord G.) % javac Library.java
Library.java:91: non-static method display() cannot be referenced from a static context
display();
^
1 error
Thanks for helping!
BR,
G-Afric

Hi folkenf,
I tried what you recommended already but the result was even more timidating.
public static void display()ERROR OUTPUT NOW IS:
Library.java:83: non-static variable bookIter cannot be referenced from a static context
bookIter = books.iterator();
^
Library.java:83: non-static variable books cannot be referenced from a static context
bookIter = books.iterator();
^
Library.java:84: non-static variable bookIter cannot be referenced from a static context
while (bookIter.hasNext()) {
^
Library.java:85: non-static variable bookIter cannot be referenced from a static context
Book aBook = (Book)bookIter.next();
^
4 errors
I fixed this error by making books and bookIter static but now main() complains
of null pointer as shown below:
Runtime error:
Exception in thread "main" java.lang.NullPointerException
at Library.main(Library.java:89)
Thanks!
BR,
G-Afric

Similar Messages

  • Don't knoe if you can help for this but i keep getting the error message " active desktop revcovery",desktop has been turned off. I followed troubleshooting tips and tried to restore. no luck. can you help?

    Desktop background turned white. shortcuts work ok.

    I think this is not a Firefox issue. Please try this: Right-click on the desktop, choose 'Properties' click the 'Desktop' tab and 'Customize Desktop' > 'Web'. Deselect or delete all the web addresses in the middle box. And click 'Ok'.

  • Can't see why I can't compile this

    I can't seem to compile this code, and yet its supposed to because this is how our professor gave it to us on the website. Can anyone tell me what I need to make it compile? Thanks in advance.
    ArrayList list = new ArrayList(5);
    list.add(0, new Object());
    list.add(new Object());
    Object object = list.remove(1);
    ArrayList<Player> players = new ArrayList<Player>(10);
    class Player implements Comparable<Player> {
      public int compareTo(Player player) {
    class PlayerNameComparator implements Comparator<Player> {
      public int compare(Player player1, Player player2) {
    class MyStack {
      public int tos;
      public Comparable list[];
      // public ArrayList<Player> list;
      public MyStack() {
        tos = 0;
        list = new Comparable[10];
      public Comparable pop() {
        tos--;
        Comparable comparable = list[tos];
        list[tos] = null;
        return comparable;
      public void push(Comparable element) {
        list[tos] = element;
        tos++;
      public String toString() {
        String data = new String();
        MyStack temp = new MyStack();
        Comparable element = null;
        while (this.tos > 0) {
          element = this.pop();
          temp.push(element);
          data = data + element.toString();
        while (temp.tos > 0) {
          this.push(temp.pop());
    }

    The compiler always produces helpful messages which describe why text won't compile. If you can't understand them it would be a good idea to post those compiler messages.

  • Can anybody help me to build an interface that can work with this code

    please help me to build an interface that can work with this code
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    hello               ahoy
    hi                    yo-ho-ho
    pardon me       avast
    excuse me       arrr
    yes                 aye
    my                 me
    friend             me bucko
    sir                  matey
    madam           proud beauty
    miss comely    wench
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

    please help me i don t know how to go about this.my teacher ask me to build an interface that work with the code .
    Here is the interface i just build
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.awt.*;
    import javax.swing.*;
    public class boy extends JFrame
    JTextArea englishtxt;
    JLabel head,privatetxtwords;
    JButton translateengtoprivatewords;
    Container c1;
    public boy()
            super("HAKIMADE");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setBackground(Color.white);
            setLocationRelativeTo(null);
            c1 = getContentPane();
             head = new JLabel(" English to private talk Translator");
             englishtxt = new JTextArea("Type your text here", 10,50);
             translateengtoprivatewords = new JButton("Translate");
             privatetxtwords = new JLabel();
            JPanel headlabel = new JPanel();
            headlabel.setLayout(new FlowLayout(FlowLayout.CENTER));
            headlabel.add(head);
            JPanel englishtxtpanel = new JPanel();
            englishtxtpanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            englishtxtpanel.add(englishtxt);
             JPanel panel1 = new JPanel();
             panel1.setLayout(new BorderLayout());
             panel1.add(headlabel,BorderLayout.NORTH);
             panel1.add(englishtxtpanel,BorderLayout.CENTER);
            JPanel translateengtoprivatewordspanel = new JPanel();
            translateengtoprivatewordspanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            translateengtoprivatewordspanel.add(translateengtoprivatewords);
             JPanel panel2 = new JPanel();
             panel2.setLayout(new BorderLayout());
             panel2.add(translateengtoprivatewordspanel,BorderLayout.NORTH);
             panel2.add(privatetxtwords,BorderLayout.CENTER);
             JPanel mainpanel = new JPanel();
             mainpanel.setLayout(new BorderLayout());
             mainpanel.add(panel1,BorderLayout.NORTH);
             mainpanel.add(panel2,BorderLayout.CENTER);
             c1.add(panel1, BorderLayout.NORTH);
             c1.add(panel2);
    public static void main(final String args[])
            boy  mp = new boy();
             mp.setVisible(true);
    }..............here is the code,please make this interface work with the code
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    hello               ahoy
    hi                    yo-ho-ho
    pardon me       avast
    excuse me       arrr
    yes                 aye
    my                 me
    friend             me bucko
    sir                  matey
    madam           proud beauty
    miss comely    wench
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

  • Can't compile this sourcecode

    why i can't compile this source code??
    if i not mistaken the error like this "can't read bla..bla(i din't remember)"
    (i've install all the java package..)
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Date;
    import java.util.Hashtable;
    * Date Servlet
    * This is a simple servlet to demonstrate server-side include
    * It returns a string representation of the current time.
    * @author Scott Atwood
    * @version 1.12, 08/29/97
    public class DateServlet extends HttpServlet {
    public void service(HttpServletRequest req, HttpServletResponse res)
         throws ServletException, IOException
    Date today = new Date();
    res.setContentType("text/plain");
    //getOutputStream ni aper?
    ServletOutputStream out = res.getOutputStream();
    out.println(today.toString());
    public String getServletInfo() {
    return "Returns a string representation of the current time";

    Try it again. And this time write down the error message you get so you can ask a coherent question.

  • How come I can't compile this file in this folder,but can in others

    import java.util.*;
    public class AlphabeticComparator
    implements Comparator{
    public int compare(Object o1, Object o2) {
    String s1 = (String)o1;
    String s2 = (String)o2;
    return s1.toLowerCase().compareTo(
    s2.toLowerCase());
    this code can be compiled in any folders except
    e:\java\
    why??? the error is:
    --------------------Configuration: j2sdk1.4.0 <Default>--------------------
    E:\java\AlphabeticComparator.java:3: AlphabeticComparator should be declared abstract; it does not define compare(java.lang.Object,java.lang.Object) in AlphabeticComparator
    public class AlphabeticComparator
    ^
    E:\java\AlphabeticComparator.java:6: inconvertible types
    found : Object
    required: java.lang.String
    String s1 = (String)o1;
    ^
    E:\java\AlphabeticComparator.java:7: inconvertible types
    found : Object
    required: java.lang.String
    String s2 = (String)o2;
    ^
    3 errors
    Process completed.

    It looks like you have a class called "Object" in that same directory that the compiler is using when you use "Object", and then the compiler complains because it wasn't "java.lang.Object". Get rid of it -- you should have called it something else, anyway.

  • Can soemone explain this code to me

    can someone explain this code to me
    import javax.swing.*;
    import BreezySwing.*;
    import java.util.Random;
    public class PennyPinch extends GBFrame
         private JButton enterButton;
         private JTextArea outputArea;
         private int[][] board = {{1,1,1,1,1},{1,2,2,2,1},{1,2,3,2,1},{1,2,2,2,1},{1,1,1,1,1}};
         private boolean[][] landing = new boolean[5][5];
         private int total;
         public PennyPinch()
         enterButton = addButton ("Pitch",2,1,1,1);
         outputArea = addTextArea("",4,1,3,4);
         public void pitch()
              Random generator = new Random();          
              int randomRow = generator.nextInt(5);
              int randomColumn = generator.nextInt(5);
              total += board[randomRow][randomColumn];
              landing[randomRow][randomColumn] = true;
         public void buttonClicked (JButton buttonObj)
              pitch();
              displayList(board, outputArea);
         private void displayList(int a[][], JTextArea output)
    output.setText("");
              for (int row = 0; row < 5; row++)
    for (int col = 0; col < 5; col++){
    if(landing[row][col] ==true)
                                  output.append(Format.justify('r',"P", 3) + " ");
                                  if (col == 4)
    output.append("\n");
                             else
                             output.append(Format.justify('r', a[row][col], 3) + " ");
                             if (col == 4)
    output.append("\n");                    }
              output.append("the total is " + total);
         public static void main (String[] args)
    PennyPinch theGUI = new PennyPinch();
    theGUI.setSize (300, 300);
    theGUI.setVisible(true);
    }

    Knowing toilets or studying under George?What kind pervert are you?
    What is written in public toilets o/c!Ah yes I see, I found example questions.
    2:3.4 please complete the following well known saying
    by filling in the blank
    Whilst you are reading what I put
    You are blank on your foot
    2:3.5 Upon seeing the announcement 'Toilet
    tennis' and following the instruction ' please
    see other wall for details' what is the standard
    message on the other wall.2:3.4. is the correct answer 'micturating' ?
    2:3.5. I believe the answer is Ibidem.

  • How  can i run this code correctly?

    hello, everybody:
        when  i run the code, i found that it dons't work,so ,i  hope somebody can help me!
        the Ball class is this :
        package {
        import flash.display.Sprite;
        [SWF(width = "550", height = "400")]
        public class Ball extends Sprite {
            private var radius:Number;
            private var color:uint;
            private var vx:Number;
            private var vy:Number;
            public function Ball(radius:Number=40, color:uint=0xff9900,
            vx:Number =0, vy:Number =0) {
                this.radius= radius;
                this.color = color;
                this.vx = vx;
                this.vy = vy;
                init();
            private function init():void {
                graphics.beginFill(color);
                graphics.drawCircle(0,0,radius);
                graphics.endFill();
    and the Chain class code is :
    package {
        import flash.display.Sprite;
        import flash.events.Event;
        [SWF(width = "550", height = "400")]
        public class Chain extends Sprite {
            private var ball0:Ball;
            private var ball1:Ball;
            private var ball2:Ball;
            private var spring:Number = 0.1;
            private var friction:Number = 0.8;
            private var gravity:Number = 5;
            //private var vx:Number =0;
            //private var vy:Number = 0;
            public function Chain() {
                init();
            public function init():void {
                ball0  = new Ball(20);
                addChild(ball0);
                ball1 = new Ball(20);
                addChild(ball1);
                ball2 = new Ball(20);
                addChild(ball2);
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            private function onEnterFrame(event:Event):void {
                moveBall(ball0, mouseX, mouseY);
                moveBall(ball1, ball0.x, ball0.y);
                moveBall(ball2, ball1.x, ball1.y);
                graphics.clear();
                graphics.lineStyle(1);
                graphics.moveTo(mouseX, mouseY);
                graphics.lineTo(ball0.x, ball0.y);
                graphics.lineTo(ball1.x, ball1.y);
                graphics.lineTo(ball2.x, ball2.y);
            private function moveBall(ball:Ball,
                                      targetX:Number,
                                      targetY:Number):void {
                ball.vx += (targetX - ball.x) * spring;
                ball.vy += (targetY - ball.y) * spring;
                ball.vy += gravity;
                ball.vx *= friction;
                ball.vy *= friction;
                ball.x += vx;
                ball.y += vy;
    thanks every body's help!

    ok, thanks for your reply ! I run this code in the Flex builder 3!and the Ball class and the Chain class are all in the same AS project!
      and i changed the ball.pv property as public in the Ball class, and  the Chain class has no wrong syntactic analysis,but the AS code don't run.so this is the problem.
    2010-04-21
    Fang
    发件人: Ned Murphy <[email protected]>
    发送时间: 2010-04-20 23:01
    主 题: how  can i run this code correctly?
    收件人: fang alvin <[email protected]>
    I don't see that the Ball class has a pv property, or that you even try to access a pv property in the Chain class.  All of the properties in your Ball class are declared as private, so you probably cannot access them directly.  They would need to be public.  Also, I still don't see where you import Ball in the chain class such that it can use it.

  • Can anyone read this Console log and tell me what is "librariand" ?

    I've been having "librariand" showing up every 2-3 minutes in my log. can anyone read this Console log and tell me what is "librariand" and what's the problem behind this ?
    11-08-14 9:53:37.009 AM librariand: new client - cancelling idle timeout
    11-08-14 9:53:37.010 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:53:37.010 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:53:37.010 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:53:37.010 AM librariand: no clients - starting idle timer
    11-08-14 9:53:37.011 AM librariand: new client - cancelling idle timeout
    11-08-14 9:53:37.011 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:53:37.012 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:53:37.012 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:53:37.012 AM librariand: no clients - starting idle timer
    11-08-14 9:53:37.013 AM librariand: new client - cancelling idle timeout
    11-08-14 9:53:37.014 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:53:37.014 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:53:37.015 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:53:37.015 AM librariand: no clients - starting idle timer
    11-08-14 9:53:37.015 AM librariand: new client - cancelling idle timeout
    11-08-14 9:53:37.015 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:53:37.016 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:53:37.016 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:53:37.016 AM librariand: no clients - starting idle timer
    11-08-14 9:53:37.017 AM librariand: new client - cancelling idle timeout
    11-08-14 9:53:37.017 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:53:37.017 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:53:37.018 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:53:37.019 AM librariand: no clients - starting idle timer
    11-08-14 9:56:39.802 AM librariand: new client - cancelling idle timeout
    11-08-14 9:56:39.803 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:56:39.803 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:56:39.804 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:56:39.804 AM librariand: no clients - starting idle timer
    11-08-14 9:57:11.575 AM librariand: new client - cancelling idle timeout
    11-08-14 9:57:11.576 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:57:11.576 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:57:11.577 AM librariand: no ubiquity account configured, not creating collection
    11-08-14 9:57:11.577 AM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 9:57:11.577 AM librariand: client connection is invalid: Connection invalid
    11-08-14 9:57:11.577 AM librariand: no clients - starting idle timer

    I completely uninstalled the following:
    Removed Evernote.app
    Removed User/Library/Preferences/com.evernote.Evernote.plis
    Removed User/Library/Applications Support/Evernote
    and still get to see these logs when restart:
    11-08-14 7:57:03.263 PM librariand: new client - cancelling idle timeout
    11-08-14 7:57:03.263 PM librariand: no ubiquity account configured, not creating collection
    11-08-14 7:57:03.263 PM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 7:57:03.264 PM helpd: unable to get sandbox extensions: The operation couldn’t be completed. (LibrarianErrorDomain error 10 - Unable to configure the collection.)
    11-08-14 7:57:03.265 PM librariand: no ubiquity account configured, not creating collection
    11-08-14 7:57:03.265 PM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    11-08-14 7:57:03.265 PM librariand: client connection is invalid: Connection invalid
    11-08-14 7:57:03.265 PM librariand: no clients - starting idle timer
    11-08-14 7:57:13.753 PM librariand: new client - cancelling idle timeout
    11-08-14 7:57:13.767 PM librariand: no ubiquity account configured, not creating collection
    11-08-14 7:57:13.767 PM librariand: error in handle_client_request: LibrarianErrorDomain/10/Unable to configure the collection.
    any other solution ?

  • How can i know how to redeem the code? how can i get this code?

    how can i know how to redeem the code? how can i get this code? please i need you help
    <Email Edited by Host>

    You are trying to create a new Apple ID? You don't have one yet? Is that correct?
    If so, then see this article on how to creat your Apple ID - and make up a password for it. Remember to write it down immediately.
    http://support.apple.com/en-us/HT203993

  • I m login in th my iphone in the itune ti download something after entering cc details its asking about something itune gift card secure code...i am not getting this..where can i get this code in order to dowanload frm itune...

    i m login in th my iphone in the itune ti download something after entering cc details its asking about something itune gift card secure code...i am not getting this..where can i get this code in order to dowanload frm itune...

    Meen0902 wrote:
    ... after entering cc details its asking about something itune gift card secure code...i
    Try the 3 or 4 digit code on the back of your Credit Card....

  • I forgot the codeslot of my ipod. How can I delete this code?

    I forgot the codeslot of my ipod. How can I delete this code? Can anybody help help me? I'm sorry for the bad English.

    Connect it to iTunes and Restore it.

  • How can i rewrite this code into java?

    How can i rewrite this code into a java that has a return value?
    this code is written in vb6
    Private Function IsOdd(pintNumberIn) As Boolean
        If (pintNumberIn Mod 2) = 0 Then
            IsOdd = False
        Else
            IsOdd = True
        End If
    End Function   
    Private Sub cmdTryIt_Click()
              Dim intNumIn  As Integer
              Dim blnNumIsOdd     As Boolean
              intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
              blnNumIsOdd = IsOdd(intNumIn)
              If blnNumIsOdd Then
           Print "The number that you entered is odd."
        Else
           Print "The number that you entered is not odd."
        End If
    End Sub

    873221 wrote:
    I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
    I'm just trying to get you to think about what your post actually says, and what others will take from it.
    what does this error mean? what code should i replace and add? thanks for all response
    C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=true;
    ^
    C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=false;
    ^
    2 errors
    Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
    It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
    So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself?

  • I downloaded the whatsapp for my phone and i can't find this code i have to put in. Help!

    i downloaded the whatsapp for my phone and i can't find this code i have to put in. Help!

    My phone had the same problem with yours before.
    Here is my solution.
    Install a software that setup an android system to your computer
    Inside the "an android system", install Whatsapp
    run Whatsapp, input your phone number to get the code
    At this time, your phone suppose to receive your code.

  • I want to install WhatsApp on my iphone 16gb, but I need a code of 3 figures! Where can I get this code? i tried looking at my messages folder, but i havent got any 3 digit code. plz help

    I want to install WhatsApp on my iphone 16gb, but I need a code of 3 figures! Where can I get this code? i tried looking at my messages folder, but i havent got any 3 digit code. plz help

    post in the iPhone forum : https://discussions.apple.com/community/iphone/using_iphone

Maybe you are looking for

  • Key mapping

    Hi All, I have 3 fields in my source file Id,Category (Key Mapping) ,Name. In Import Manager I have mapped Remote Key field with ID . Name with Name category with Category Qualified Range (A 1-10) I have source file like this Id name category 11  10 

  • Creation of new condition type: MWST

    Hi, Everyone. I would like to ask for some help regarding this issue: Creation of new condition type: MWST with the following details: 1. For the country French Polynesia, Create a new VAT condition of 10%. 2. Create a new one called : Class : Z u201

  • Attaching pdf files to e-mails ?

    when I try to attach a pdf to my email it only attaches the first page. I run mavericks ?

  • Autoconfig issue after upgrading 12.1.1 to 12.1.3

    Hi all, I am getting below mention autoconfig issue after upgrading 12.1.1 to 12.1.3. jtfictx.sh started at Mon Mar 28 08:28:50 EDT 2011 SQL*Plus: Release 10.1.0.5.0 - Production on Mon Mar 28 08:28:50 2011 Copyright (c) 1982, 2005, Oracle. All right

  • Hot spot in Bar chart

    Hi,     I have a requirement where I need to maintain hotspot for the graphical bars of the barchart. How can it be accomplished. There is a standard demo program BARCBO02 for Barcharts, but hotspot is not provided. Please let me know how it can be a