Florin Florentin

Ranch Hand
+ Follow
since May 12, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Florin Florentin

Hello.

I am creating an activity which contains one table. When selecting a row, i want to update or delete the row through context menu options.
The table is within TableLayout view. Each row is added to the TableLayout as a TableRow view, and also for each TableRow i registered it for context menu with registerForContextMenu(tr);

The context menu options are displaied when selecting a row, but the problem is that i need the number of the selected row . I tought that this could be achieved with the following source code in the onContextItemSelected( MenuItem item ) method :


but the AdapterContextMenuInfo is always null.

Could i achieve the table row by other method?
6 years ago
Joe it is correct what you think.
Is it then correct to afirm that when using generics, type information is erased to it's first bound, except list, where type information is erased to the raw type?

Sorry for the late response. I was away a couple of days.

Thank you for your answers, but i want to know why it's this behaviour.
Thank you for the answer.

Wouter Oet wrote:

The second part will not compile because of the name clash due to type erasure. The type erasure will (simply put) convert the methods to something like this:
public void t1(List) { }
public void t1(List){ }



Why doesn't it is compiled to :

public void t1(List<java.lang.Object>) { }
public void t1(List<java.lang.String>){ }

?
Hello. I have a question about overloading / type erasure.

The following code compile and runs. I think (that's only my opinion, so if i'm not right i would love to be corrected) because T it's erased in the second function to String, and in the first it is erased to Object, so there are different arguments.




The following code isn't compiling. It's saying that the methods have the same erasure t1(List<T>).



Why is in the list example a different behavior?
Ankit Garg is right, he said why when i have a collection the compilation fails : "Here even if T somehow resolves to Number, you can't pass Collection<Double> to Collection<Number> ".

Mark i don't think you are right. You are saying that the order of the argument matters, and the second argument must pass the IS-A test with the first strict type, but you are not right. Following you, the next code would not compile , but it does :


Thank you for your quick replies and you help Mark. You helped me .

One more question. In this case,



the code compiles, so why here the second argument must not be a supertype of the first type? Maybe it's a silly question but i don't know why.
Thank you Mark.

I am only trying to get how type inference is working, so i don't need suggestions to change the function definition.

I would to ask again why this is working,



and this is NOT working :

I was not talking about polymorphic assignements.
I am asking why



is not working, but instead



is working.

I think it's about type inference. I see that if the collection has a supertype type of the Integer, i can call the test method, if it's a subtype, i can't call it. I am asking why is this way?
Of course making the same types will work, i am sure about that. But i was asking why is it not working now, maybe i wasn't very clear
I would like to ask a question about type inference.
In the following code, why the Collection type must be of a type which is a supertype of the first argument ? The next code isn't working, but if i would had a collection of Number or Objcet it would be ok.



I thought that in the following code, the type would be inferred to Number, but i guess i am wrong, and i don't understand why. I hope i am clear
Hello.

I have a question about working and writing to files. I tried to write to a file using a BufferedWriter, and then use the same BufferedWriter to write to a new file. I've created a new FileWriter object, in which constructor i've passed a new file reference, but that not worked as i was expecting.

Here is the code :



After i'm running this code, there is no text been writed in f2. It's been writed twice in f1.
If i insert this
bw = new BufferedWriter(fw);
on the "//insert code" line, the code will run as i want, but i don't understant why it's not enough to make only fw refering to a new object ?

Is this a String related behavior?