• 15

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Variables with underline

I'm getting an underline in some variables on Android Studio (in this case on the 'position' variable). I think it's not an error because the application runs perfectly and the compiler passes everything ok. I'm wondering what does that mean?

enter image description here

It could be a sign of "Reassigned parameter"

enter image description here

  • 33
Reply Report
      • 2
    • The reassigned marker "Underscored" in Language Defaults is now also used for reassigned variables not only parameters. I made parameters now "Bold Underscored" to even distinguish it further.
      • 1
    • Also appears for reassigned local variable. Just turn it off if it bugs you (it bugs me--I like to build variables step-by-step, which always flags this pseudo-warning).

I believe the underlined variables are representative of constants (final or effectively final), because in my experience I only see this decoration when I declare a final object for use inside an anonymous class. I can't seem to find it in the documentation, though.

  • 20
Reply Report

I've found the answer for this question here.

The decoration is a syntax highlighting preference. Take a look at File > Settings > Editor > Color Scheme > Java/Kotlin

In the case of Java, you can find this effect for example at Parameters > Implicit anonymous class parameter. It's the checkbox Effects.

enter image description here

The same with Kotlin at Properties and Variables > Var (mutable variable, parameter or property).

enter image description here

  • 12
Reply Report

This means the variable was declared outside the current method. For example, in this case, position is probably declared as a class member outside the new DialogInterface.OnClickListener(), in the class where you're implementing the onItemLongClick() method.

They are declared like this:

public class MyClass{
    private int position;

    // Other code...

  • 3
Reply Report

It may be because a immutable variable is subjected to modification. Like reassigning a String or trying to modify a final declared variable.

String buffer = "";
buffer = buffer + "new string";

Will underline the buffer, since string are of immutable Objects.

  • 1
Reply Report