Explanation :
           I am trying to cast my view elements in kotlin. In kotlin there is only possible in onCreate() but the problem is the scope of this variable or view elements inside the onCreate() method only. I tried to declare outside the onCreate() and inside the class. It raised me an error.
Please help me to resolve.
class MainActivity : AppCompatActivity()
{ 
    var x:Int = 10; 
    var lblValue:TextView=findViewById(R.id.lbl_value); 
    override fun onCreate(savedInstanceState: Bundle?) { 
       super.onCreate(savedInstanceState) 
       setContentView(R.layout.activity_main) 
       lblValue.setText(""+getSum(10,20)); 
    } 
    fun getSum(a:Int,b:Int): Int{ 
      return a+b; 
    } 
} 
 
    