Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

char equals java

just use == and !=
Comment

char equals java


  @Test
  public void testCharacterEquals() {
    //primitive type uses == operator for equals comparasion
    char a1 = 'A';
    char a2 = 'A';
    if (a1 == a2) {
      System.out.println("primitive type comparasion: it's equal");
    }

    //From Java doc; The Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.
    //Object type uses equals method for equals comparasion
    Character character1 = 'A';
    Character character2 = 'A';
    if (character1.equals(character2)) {
      System.out.println("object type comparasion: it's equal");
    }
  }

Comment

PREVIOUS NEXT
Code Example
Java :: android studio fragment findviewbyid 
Java :: how to make an activity default in android studio 
Java :: random number between 1 and 100 java 
Java :: how to check grant permissions in android 
Java :: slice array java 
Java :: get text from edittext android 
Java :: java 2d array loop 
Java :: what is an error in java 
Java :: java stream order by property 
Java :: how to print array 
Java :: how to add music to java 
Java :: How to add music to andoid project 
Java :: char default value in java 
Java :: object to double java 
Java :: java 8 functional interfaces 
Java :: factorial of a number using recursion in java 
Java :: print * pattern in java 
Java :: optional throw if present 
Java :: convert int to string java 
Java :: how to resize image in android programmatically 
Java :: generate random color in java in android 
Java :: android create snackbar 
Java :: how to read file from assets folder in android 
Java :: how to create a stack data structure in java? 
Java :: how to convert epoch time to date in java 
Java :: close a popup selenium python 
Java :: view get text android 
Java :: java read keyboard input 
Java :: java map to list or array 
Java :: android play sound file from assets 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =