incompatible types: int cannot convert to String

Discussion in 'Java' started by Noraini ibrahim, Jul 9, 2015.

?

how to solves this kind of error?

  1. java

    0 vote(s)
    0.0%
  2. netbeans

    1 vote(s)
    100.0%
Multiple votes are allowed.
  1. Noraini ibrahim

    Noraini ibrahim

    Joined:
    Jul 9, 2015
    Messages:
    1
    Likes Received:
    0
    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {




    String name;
    name = jTextField1.getText();

    int i;

    for(i=0;i<std.length;++i)
    {
    if(std.getName().equals(name))
    {
    jTextField2.setText(name);
    jTextField3.setText(((Student)std).calcYob());
    jTextField4.setText(((Student)std).calcAge());
    jTextField5.setText(((Student)std).calcGender());
    jTextField6.setText(((Student)std).calcBmi());

    break;
    }
    }
    }
     
    Noraini ibrahim, Jul 9, 2015
    #1
    1. Advertisements

  2. Noraini ibrahim

    Abhinn

    Joined:
    Aug 28, 2016
    Messages:
    2
    Likes Received:
    0
    It means that you are giving string type,s in a int variable.
     
    Abhinn, Aug 28, 2016
    #2
    1. Advertisements

  3. Noraini ibrahim

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    98
    Likes Received:
    14
    Location:
    Malaysia
    In which line you getting such error ?
     
    John Joe, Apr 25, 2017
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.