Type mismatch: cannot convert from integer to boolean

后端 未结 7 1216
忘了有多久
忘了有多久 2020-12-06 01:48
public boolean clearSelection() {
    int i = 0;
    if (!this.m_SelectedComps.isEmpty()) {
        i = 1;
        Iterator localIterator = this.m_SelectedComps.iter         


        
相关标签:
7条回答
  • 2020-12-06 02:21

    You can't type cast between integer and boolean in Java but you could use the following technique which I use oftenly:

    To convert boolean into integer:

    int i;
    return i != 0;
    

    To convert integer into boolean:

    boolean b;
    return b ? 1 : 0;
    
    0 讨论(0)
提交回复
热议问题