Questions tagged [downcast]

Downcasting permits an object of a superclass type to be treated as an object of any subclass type.

589 questions
-1
votes
3 answers

TextView textView = (TextView) findViewById(R.id.textView) is Upcasting or Downcasting?

I am totally confused as to below code does upcast or downcast. If so how? Is TextView a super class, I presume its a sub-type of View. TextView textView = (TextView) findViewById(R.id.textView);
Yuvraj Mudaliar
  • 375
  • 5
  • 15
-1
votes
3 answers

C++ Downcasting a struct

I have the following code: struct Operation { public : OperationName name; }; struct FilterOperation : Operation { FilterName filter; std::list params; }; The OperationName and FilterName are enums listing all the…
Estefunny
  • 43
  • 1
  • 10
-1
votes
2 answers

How come when downcasting I don't have to use an initializer of ItemsTableViewController? Is it initialized?

I'm working through a tutorial and I noticed that when downcasting I didn't have to use an initializer method of the object. Is the object initialized? In the AppDelegate codebase below, I'm referring to the ItemsTableViewController. All I had to…
Laurence Wingo
  • 3,912
  • 7
  • 33
  • 61
-1
votes
1 answer

Downcasting Superclass to Subclass passes instanceof but encounters ClassCastException

I have two objects, User and CustomUserDetails which extends User and implements org.springframework.security.core.userdetails.UserDetails; In my repository layer I make a call to my in-memory database and retrieve a user. public User…
shirafuno
  • 387
  • 3
  • 9
  • 24
-1
votes
1 answer

How scope related with timesheet in versionOne?

I am completely new in VersionApi implementaion. Before starting I would like to gather a initial information like below: How can we fetch Scope/Project using VersionOne API? How scope and Timesheet mapped with each other, where I can get that…
Prashant K
  • 11
  • 3
-1
votes
1 answer

After downcasting a supertype object to subtype , when I call any method on the supertype object, they are not actually invoked

class A{ void amethod(){ System.out.println("amethod"); } void overridenmethod(){ System.out.println("in A"); } } class B extends A{ void bmethod(){ …
shrishti
  • 95
  • 5
-1
votes
1 answer

Java: Disclosing protected value from object static Class using casting

Note: I found multiple information about disclose (get) value of protected fields or members of some class, my difference its a need to obtain of instanced objects... Hi, I want to disclose information the previously instanced static Inner class…
user8086455
-1
votes
1 answer

How to detect if an array of a numeric type only contains boolean values?

I'm writing a data pre-processor for machine learning, which needs to treat boolean data as categories and not try to see 1 as bigger than 0. After importing a csv table with Pandas DataFrame I want to determine columns which are boolean and cast…
Robert Peetsalu
  • 126
  • 1
  • 6
-1
votes
1 answer

Why C# downcast become always null?

So here is my code, public void CheckStatChal() { foreach (SpotUIBase menu in thisSpot.ownMenus) { if (menu.uiSort == SpotUISort.StatEvent) { if(menu != null) Debug.Log("Menu name is…
creator
  • 671
  • 11
  • 28
-1
votes
1 answer

Java Downcasting of extending class

Why this code is not working? When i casting, I get ClassCastExeption Exception in thread "main" java.lang.ClassCastException: A cannot be cast to B at HelloWorld.main public class HelloWorld { public static void main(String[] args) { B…
A. Kashnikov
  • 143
  • 2
  • 11
-1
votes
1 answer

Downcast interface to Integer

public static void InsertionSort(Comparable[] a, int length){ for (int i = 1; i < length; i++){ for(int j = i; j > 0; j--){ if(a[j].compareTo(a[i]) > 0){ Integer b = (Integer)a; …
Ninja Dude
  • 1,332
  • 4
  • 27
  • 54
-1
votes
2 answers

Downcasting fails

I encountered little unusual down casting failure. I have a class Vehicle in FrameworkA FrameworkA open class Vehicle { open var name: String = "" } And I subclassed this Vehicle class in other project. Project import FrameworkA class Car:…
Ryan
  • 4,799
  • 1
  • 29
  • 56
-1
votes
2 answers

when downcasting is possible in java?

I have a basic question in java. from my research I found out that downcasting is not allowed in java because it throws an exception in runtime but in some limited cases such as Downcasting in Java But I can't understand why this statement proceeds…
Mostafa zamani
  • 78
  • 1
  • 12
-1
votes
2 answers

Converting base to derived class

In the following code although the instances of subclass are getting pushed on the stack of base class but while retrieving(top operation) an element and storing it in derieved class object, the compiler is generating an error. #include…
sv_jan5
  • 1,543
  • 16
  • 42
-1
votes
2 answers

What use does the new as! operator have?

I don't quite understand what new functionality the as! operator is supposed to add. Apple's documentation says: The as! operator performs a forced cast of the expression to the specified type. The as! operator returns a value of the specified…
Marcus Rossel
  • 3,196
  • 1
  • 26
  • 41