Error when Using getSupportActionBar in Android Studio : I have an android project. I used android studio.
In my project, I want to change the Title project with getSupportActionBar().setTitlte(), but I got an error.

**Error** :

    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime: FATAL EXCEPTION: main
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime: Process: com.mynotescode.apps.layout, PID: 16441
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mynotescode.apps.layout/com.mynotescode.apps.layout.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2326)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:147)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5264)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at com.mynotescode.apps.layout.MainActivity.onCreate(MainActivity.java:18)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5975)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:147) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5264) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900) 
    08-02 06:58:48.645 16441-16441/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695) 

**This is my MainActivity.java :**

    package com.mynotescode.apps.layout;
    
    import android.os.Bundle;
    import android.support.v7.app.ActionBar;
    import android.support.v7.app.AppCompatActivity;
    import android.view.Menu;
    import android.view.MenuItem;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            ActionBar actionBar = getSupportActionBar();
    
            actionBar.setTitle("Hotel Hilton");
            actionBar.setSubtitle("Isla Nublar");
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.menu_main, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
    
            //noinspection SimplifiableIfStatement
            if (id == R.id.action_bookmark) {
                return true;
            }
    
            if (id == android.R.id.home){
                finish();
            }
    
            return super.onOptionsItemSelected(item);
        }
    }


Please help me. Thank you.