How do i convert void to boolean?

Hi all,
My problem is:
This is one kind of java puzzle.
if(System.out.println("I can "))
The above sentence make the error like as incompatible type.cannot convert "void" to "boolean".Now I try to typecast void to boolean. It is not working at anyway.Please any have exposure about void to Object conversion.Please guide me.

Don't put all your faith in Schrodinger....
I repeated the "Schrodinger Cat" experiment, and
could determine whether the cat was alive or dead.
It was a function of time. After 4 or 5 days,
s, the outcome was deterministic.Schr�dinger's Cat is bad OO. The cat does know its
state, and that info should remain encapsulated. If
you need it, you can still reference the animal and
query it.Wouldn't the cat's state be more like a variable that has only been declared but not initialized? :^)
- Saish

Similar Messages

  • How do u convert string to boolean?

    Hi ,
    Please find attached part of as vi. Global string is a global variable of string type. I would like to know how to connect it to the  rest of the block diagram. The case structure shown is of boolean type.The global string must display the color indicated in the case structure which  is red .
    Thanks
    SR
    Attachments:
    issue.ppt ‏81 KB

    If you do something like the attached picture, it will set the value of a string indicator and color the text either red or green. You are making things way too complicated and the code you've tried to implement isn't even close to what you want to accomplish and the Boolean to String isn't what was suggested in your other post on the subject.
    Message Edited by Dennis Knutson on 07-18-2006 12:22 PM
    Attachments:
    Set Text Color.JPG ‏8 KB

  • How can i pass the values to method public static void showBoard(boolean[][

    I need x and y to pass to the method
    public static void showBoard(boolean[][] board
    i am very confused as to why its boolean,i know its an array but does that mean values ar true or false only?Thanks
    import java.util.Random;
    import java.util.Scanner;
    public class Life1
         public static void main(String[] args)
              int x=0;
              int y=0;
              Scanner keyIn = new Scanner(System.in);
              System.out.println("Enter the first dimension of the board : ");
              x = keyIn.nextInt();
              System.out.println("Enter the second dimension of the board : );
              y = keyIn.nextInt();
              boolean[][] board = new boolean[x][y];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < x; row++)
                   for(col=0; col<y; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

    this is what im workin with mabey you can point me in the right directionimport java.util.Random;
    /* This class creates an application to simulate John Conway's Life game.
    * Output is sent to the System.out object.
    * The rules for the Life game are as follows...
    * Your final version of the program should explain the game and its use
    * to the user.
    public class Life
         public static void main(String[] args)
              //Allow the user to specify the board size
              boolean[][] board = new boolean[10][10];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < 10; row++)
                   for(col=0; col<10; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

  • How can I convert a String into boolean?

    I am facing difficulty in converting String into boolean.
    For example, I have a few variable which i need user to input yes or no as the answer. But I uses string instead. Is there a way which i can ask them to input boolean directly?
    Please advise...
    credit = JOptionPane.showInputDialog("Enter Yes or No for Credit Satisfactory : ");
    System.out.println("The answer for Credit Satisfactory : "+credit);
    e_invtry=JOptionPane.showInputDialog("Enter Yes or No for inventry level");
    System.out.println("The answer for Quantity Order : "+e_invtry);
    Message was edited by:
    SummerCool

    Thanks...but I don't get it....I tried to use your
    suggestion but i got the message that " cannot find
    symbol method
    showConfirmDialog(java.lang.String,int)" ???
    Please advise.
    The code I use was :
    int credit = JOptionPane.showConfirmDialog("Enter Yes
    or No for credit satisfactory",
    JOptionPane.YES_NO_OPTION);Well that was not the example I gave you.
    JOptionPane has no method showConfirmDialog that receives a String and an int (exactly what the error message is telling you).
    What was wrong with the version I showed you?

  • Converting integer for boolean

    I�m raw in Java, and I want to know how to convert ao type that is in integer to boolean?
    Here is the program.
    import java.io.*;
    import java.lang.*;
    public class binario{
         public static void main(String args[]) throws IOException{
              System.out.print("Digite um numero qualquer ");
              InputStreamReader a = new InputStreamReader(System.in);
              BufferedReader teclado = new BufferedReader(a);
              //String b = new String
              int b = Integer.parseInt(teclado.readLine());
              b = 0;
              while (b/2){//I wanto to convert this for boolean or integer for to compare if is divisible for 2.
                   if (b%2 != 0)
                        System.out.println(1);
                   else
                        System.out.println(0);
                        b=b+1;               
    Thank you very much for help.
    Paulo
    [email protected]
              

    You want something like
    bool = (b%2==0? true:false) or maybe vice-versa.
    Answer provided by Friends of the Water Cooler. Please inform forum admin via the 'Discuss the JDC Web Site' forum that off-topic threads should be supported.

  • How can I convert an int to a string?

    Hi
    How can I convert an int to a string?
    /ad87geao

    Here is some the code:
    public class GUI
        extends Applet {
      public GUI() { 
        lastValue = 5;
        String temp = Integer.toString(lastValue);
        System.out.println(temp);
        showText(temp);
      private void showText(final String text) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            tArea2.setText(text + "\n");
    }

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • How can I convert a Database Handle from TestStand to LabVIEW?

    I want to use a Database Handle (already created in TestStand by an Open Database step) in a LabVIEW-VI (called from TestStand) to connect it with the "Connection Reference" input of the "Easy SQL.vi"? If I use a directly connection via the "TestStand - Get Property Value (Number).vi" I get back the error message 4101 in LabVIEW. How can I convert the Database Handle?
    Test Engineering
    digades GmbH
    www.digades.com

    The TestStand database step types use the CVI SQL Toolkit to talk to databases. The handle that you are referencing is an internal memory location and not a actual handle that you can directly use. Currently as implemented the handle that is stored in a numeric TestStand property for the connection and the SQL statement are the handle values returned from the CVI SQL Toolkit. So for the connection handle, you could call the CVI SQL Toolkit function
    DBGetConnectionAttribute (
    int Connection_Handle,
    tDBConnectionAttr Attribute,
    void *Value);
    and get the CVI CAObjHandle reference. With this you could then call the CVI ActiveX function
    CA_GetInterfaceFromObjHandle(
    CAObjHandle Object_Handle,
    const IID *Interface_Id,
    int Force_AddRef,
    void *Inte
    rface_Ptr,
    int *Did_AddRef);
    to get the actual ActiveX interface reference. This would have to be converted into a LabVIEW reference.
    You may want to consider just using LabVIEW to open a new parallel reference only using the toolkit.
    Scott Richardson
    National Instruments

  • How do I convert a Vector to be passed into the session

    Hi I have a vector in a JSP that I need to pass on to a second JSP. I use the following command to do that just as I pass normal other strings:
    session.setAttribute("MyVector",vecData);
    But the follwoing error is been thrown by Tomcat.
    Incompatible type for method. Can't convert void to java.lang.Object.
    out.print(session.setAttribute("ResultsSet",set));
    ^
    I guess I have to convert it explicitly into an object and then how do I do that? could someone please help me fast on this?
    if this doesn't work is there some other way to send this vector to my other page? I am currently sending enough strings using the above method, but for Vectors it doesn't seem to work though I am told that a session object can carry any object unlike the request object that carries only strings. Please help!!!!

    Hi Calin thank you so much for taking ur time to help me with my problem.
    well let me explain my requirement fully in detail. JSP1 has a form on it for the user to fill in. its in the form of a table with multiple rows. say as in entering product details one after the other in an invoice.
    I want each of these rows taken in and passed into JSP2.
    What I do is pack each row of the table into a hashtable using a 'for' loop.
    Then I add each record (within the 'for' loop) to a Vector. After the 'for' loop, outside of it, I set this Vector to the session as :
    session.setAttribute("RecordSet",vecRecordSet);
    Well let me copy paste and extract of the coding from my source which shows what I have done.
    Vector set=new Vector();
    for (int i=0;i<Integer.parseInt(request.getParameter("NoOfRecords"));i++)
    Hashtable Record=new Hashtable();
                   Record.put("ReminderStatus",ReminderStatus);
                   Record.put("CustomerNo",CustomerNo);
                   Record.put("CustomerName",CustomerName);
                   Record.put("Address",address);
                   Record.put("ContractNo",ContractNo);
                   Record.put("MachineID",MachineID);
                   Record.put("ModelNo",ModelNo);
                   Record.put("Description",description);
                   Record.put("SerialNo",SerialNo);
                   Record.put("ContractValue",ContractValue);
                   Record.put("NoOfServices",NoOfServices);
                   Record.put("ContractStartDate",ContractStartDate);
                   Record.put("ContractEndDate",ContractEndDate);               set.add(Record);
         session.setAttribute("ResultsSet",set);//SHERVEEN
    well don't worry about the for loop condition up there cos it works for the main functionality that exists within the for loop. but what seems to go wrong is when I add records to the hashtable and when I pack it to the Vector "set"
    I hope I have not done something wrong as a principle over here.
    And btw the error that I showed u before, is pointed at a row which exists in the file that is generated when compiled. the out.println part is generated in that file during compilation and I don't know why.
    I hope I have given u information for u to make some sense of my requirement and thank u a million once again for ur effort to help me out. I am grateful to all of u.

  • Converting String to boolean not working

    Hello there - I am having a bit of trouble - I am trying to write a program to evaluate boolean expressions (fully parenthesized) As StringTokenizer goes through the expression, the boolean values are being pushed (as Boolean objects) and popped (converted to String) correctly, but the expression I am using to evaluate them is evaluating false (see my debug below)
    In my current code, I have op1 and op2 coming off of the stack as Strings but am not sure if Boolean.getBoolean() is the right method to use to convert them to boolean values. The Sun docs weren't very helpful and there wasn't anything that I could find on the Sun forum about converting Strings to boolean (vs. Boolean). This is what my evaluate code looks like:
    if (operation.equals("||")) {
    opB1 = Boolean.getBoolean(op1);
    opB2 = Boolean.getBoolean(op2);
    test = (opB1 || opB2);
    System.out.println("test = (opB1 || opB2) " + (opB1 || opB2)); //debug
    System.out.println("opB1 = " + opB1 + " opB2 = " + opB2); //debug
    In the above example - using the expression "( ( 1 < 2 ) && ( 2 > 1 ) )" my debug reads like this:
    Operator added to stack is (
    Operator added to stack is (
    Operand added to stack is 1
    Operator added to stack is <
    Operand added to stack is 2
    Operation removed from stack is <
    Operand removed from stack is 2
    Operand removed from stack is 1
    Boolean operand added to stack is true
    Operation removed from stack is (
    Operator added to stack is &&
    Operator added to stack is (
    Operand added to stack is 2
    Operator added to stack is >
    Operand added to stack is 1
    Operation removed from stack is >
    Operand removed from stack is 1
    Operand removed from stack is 2
    Boolean operand added to stack is true
    Operation removed from stack is (
    Operation removed from stack is &&
    Operand removed from stack is true //NOTE: values are both true
    Operand removed from stack is true
    test = (opB1 && opB2) false //NOTE: expression is evaluating as false
    opB1 = false opB2 = false //NOTE: converted String went from true to false!!
    Boolean operand added to stack is false
    Operation removed from stack is (
    When I changed the type of opB1 & opB2 to type Boolean, and use:
    if (operation.equals("||")) {
    opB1 = Boolean.valueOf(op1);
    opB2 = Boolean.valueOf(op2);
    test = (opB1 || opB2);
    System.out.println("test = (opB1 || opB2) " + (opB1 || opB2)); //debug
    System.out.println("opB1 = " + opB1 + " opB2 = " + opB2); //debug
    I get an error that || and && can't be used on type Boolean.
    I've spent several hours on this boolean part alone - any suggestions? (BTW - sorry for the long message!)

    You're a genius!! Wow I never would have figured that one out in a million years!! BTW - can you tell me how you got your code to be so nicely formatted in the post?
    Everytime I cut and paste - it looks aweful and all of the indentations are gone...
    Thanks again!!!

  • How do i convert String type to an BinaryEntry Type ?

    We have to differentiate between keys that come to Erase method of custom publisher. So, we appended "|" at the end of the key as below
    key = "a"; //Actual key that is in Cache
    if(//some condition)
    newKey = "a|"; //newKey to differntiate
    getCache().remove(newKey);
    else
    getCache().remove(key);
    Now, the call comes to Erase method of our custom publisher. Here, we need to perform different operation for the key which has "|" in it. So, we added below code in custom Erase method.
    public void erase(BinaryEntry binEntry)
    String key = (String) binEntry.getKey();
    if(key.contains("|"))
    //Need to perform some DB operation here. Then,
    //now the key is "a|". we need to remove the "|" symbol and call erase method to remove the actual key ("a") from cache. So we added below code
    String newKey = (dnsDomainName).replace("|", "");
    //Here the problem is, key is of type String. But, Erase method can take only BinaryEntry type. So, we tried this
    binEntry = (BinaryEntry)(binEntry.getContext().getKeyToInternalConverter().convert(key));
    super.erase(binEntry); //but it dint work. The entry is not getting deleted from Cache.
    //How do we convert the key that is of String type to BinaryEntry ?
    else
    super.erase(binEntry);
    Can someone suggest ?

    LSV wrote:
    We have to differentiate between keys that come to Erase method of custom publisher. So, we appended "|" at the end of the key as below
    key = "a"; //Actual key that is in Cache
    if(//some condition)
    newKey = "a|"; //newKey to differntiate
    getCache().remove(newKey);
    else
    getCache().remove(key);
    Now, the call comes to Erase method of our custom publisher. Here, we need to perform different operation for the key which has "|" in it. So, we added below code in custom Erase method.
    public void erase(BinaryEntry binEntry)
    String key = (String) binEntry.getKey();
    if(key.contains("|"))
    //Need to perform some DB operation here. Then,
    //now the key is "a|". we need to remove the "|" symbol and call erase method to remove the actual key ("a") from cache. So we added below code
    String newKey = (dnsDomainName).replace("|", "");
    //Here the problem is, key is of type String. But, Erase method can take only BinaryEntry type. So, we tried this
    binEntry = (BinaryEntry)(binEntry.getContext().getKeyToInternalConverter().convert(key));
    super.erase(binEntry); //but it dint work. The entry is not getting deleted from Cache.
    //How do we convert the key that is of String type to BinaryEntry ?
    else
    super.erase(binEntry);
    Can someone suggest ?Excuse me, but you write here totally does not make sense on its own.
    1. What class is this method on?
    2. Why do you want to use a key in the place of an entry?
    If I correctly interpret what you try to achieve, your super-class implementation has to know how to deal with the trailing pipe character as you are never supposed to change the key on an entry, and the entry without the pipe does not exist either.
    Best regards,
    Robert

  • I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    The application Acrobat provides no language translation capability.
    If you localize the language for OS, MS Office applications, Acrobat, etc to the desired language try again.
    Alternative: transfer a copy of content into a web based translation service (Bing or Google provides a free service).
    Transfer the output into a word processing program that is localized to the appropriate language.
    Do cleanup.
    Be well...

  • How can I convert an audio file (speech) into a text?

    Hello everybody!
      Can someone explain how I can convert a garageband file (voice speech) into a text? My Mac is a Mac OS X 10.5.8 version, so I don't have programs such as mountain Lion. I thought to use googlevoice. Is this option available? If yes, how can I use it?
    Thanks.

    Hello, I only find google voice available for Abdroid!?
    http://www.ehow.com/info_10033225_google-voice-system-requirements-android.html
    Some possibilitities, not sure if they have 10.5.8 compatble versions anymore...
    http://atmac.org/speech-to-text-dictation-software-for-os-x
    Some reviews of later Dragon Speak...
    http://www.finetunedmac.com/forums/ubbthreads.php?ubb=showflat&Number=22962

  • How do I convert my existing iTunes account to a .mac account?

    I am trying to convert my existing iTunes account which uses an Earthlink address. The following is the INSTRUCTIONS from the Apple web site on how to do this.
    "I just signed up for .Mac. How do I convert my existing iTunes account to
    my new .Mac account?
    We'll be happy to convert your account for you. Please provide your old account name, your new .Mac account name and your billing address in your email. We will also need your explicit permission to reset your password to complete the conversion."
    This is the URL where I found those INSTRUCTIONS:
    http://www.apple.com/support/itunes/musicstore/email/
    I FOLLOWED THE INSTRUCTIONS ABOVE!
    I am now on my fifth exchange of emails with iTunes support.
    HAS ANYBODY SUCCESSFULLY EXECUTED THESE INSTRUCTIONS? I don't want to lose the ability to play my existing purchased music, but I want to close down Earthlink as my ISP.
    17" G4 Powerbook   Mac OS X (10.4.6)  
    17" G4 Powerbook   Mac OS X (10.4.6)  

    On any page in the iTunes Store, click the flag icon at the lower right.  This brings up a page saying "Choose your country or region."  Click Canada.
    Before you can buy anything, you will need to enter your Canadian credit card.

  • How can I convert an OVM vm (.img) to VDI (virtualbox)?

    Hi,
    how can I convert an OVM vm (.img) to VDI (virtualbox)?
    Is .img format a raw image? If yes can I use "VBoxManage convertdd" to convert from .img to vdi?
    tnx & regards,
    S.

    Hi,
    "VBoxManage convertdd" solved.
    Regards,
    S.

Maybe you are looking for