final

Firing events from dynamically added html

久未见 提交于 2019-12-12 19:25:09
问题 i have to load Html data from server like i have 'click' but when i assign this data to innerHtml property in angular2 it shows html but click even is not working . is there any solution for this problem. there are some suggestions to use dynamic Components but i don't find any good tutorial for final angular2 release. import { Component, ViewChild, ElementRef, OnInit, Directive } from '@angular/core'; import { HttpComponent} from './http.component'; import {DomSanitizer, SafeHtml} from '

Java comparator uses non final variables

爱⌒轻易说出口 提交于 2019-12-12 17:25:40
问题 I want to sort a list, using a map which contains the values for each item. Map<Integer, Float> map = new HashMap<>(); List<Integer> list = new ArrayList<>(); map.put(0, 0.0f); map.put(1, 5.0f); map.put(2, 2.0f); list = new ArrayList<>(map.keySet()); Collections.sort(list, new Comparator<Integer>() { public int compare(Integer left, Integer right) { Float leftCost = map.get(left); Float rightCost = map.get(right); return leftCost.compareTo(rightCost); } }) I want the order to be 0,2,1 because

MD5工具类

孤街浪徒 提交于 2019-12-12 16:51:42
public class MD5Util { static final int S11 = 7; static final int S12 = 12; static final int S13 = 17; static final int S14 = 22; static final int S21 = 5; static final int S22 = 9; static final int S23 = 14; static final int S24 = 20; static final int S31 = 4; static final int S32 = 11; static final int S33 = 16; static final int S34 = 23; static final int S41 = 6; static final int S42 = 10; static final int S43 = 15; static final int S44 = 21; static final byte[] PADDING = { -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

How to “safely publish” lazily-generated effectively-immutable array

孤街醉人 提交于 2019-12-12 16:25:10
问题 Java's present memory model guarantees that if the only reference to an object "George" is stored into a final field of some other object "Joe", and neither George nor Joe have never been seen by any other thread, all operations upon George which were performed before the store will be seen by all threads as having been performed before the store. This works out very nicely in cases where it makes sense to store into a final field a reference to an object which will never be mutated after

private static final double is 0

我与影子孤独终老i 提交于 2019-12-12 14:47:09
问题 I am trying to use the following line to specify a double constant, can anybody help explain to me why at runtime this constant has a value of 0.0 : private static final double CONSTANT = 1/2; 回答1: 1 and 2 are interpreted as integers and produce integer result of division. Add D at the end to make them interpreted as doubles. private static final double CONSTANT = 1D/2D; 回答2: The constant ends up with a value of 0.0 because the result of integer division is an integer, truncated. So your the

Thread Safe - final local method variable passed on to threads?

跟風遠走 提交于 2019-12-12 10:35:47
问题 Will the following code cause same problems, if variable 'commonSet' of this method was instead a class level field. If it was a class level field, I'll have to wrap adding to set operation within a synchronized block as HashSet is not thread safe. Should I do the same in following code, since multiple threads are adding on to the set or even the current thread may go on to mutate the set. public void threadCreatorFunction(final String[] args) { final Set<String> commonSet = new HashSet

Compile time error “final variable is not initialized”

余生长醉 提交于 2019-12-12 03:48:47
问题 I have an issue, while trying few code snippets i came across a code class O { final int i; O() { i=10; } O(int j)// error here as THE BLANK FINAL FIELD i IS NOT INITIALIZED { j=20; System.out.println(j); } } class Manager3 { public static void main(final String[] args) { O n1=new O(); //O n2=new O(10); //n1.i=20; //System.out.println(j1.i); } } but if i comment the constructor with parameter i do not get any errors. My question is why am i getting this compile time error when i put both the

Interface Variables

♀尐吖头ヾ 提交于 2019-12-12 01:02:44
问题 public interface A { public final int a = 0; } Many books say that all variables (constants) in an interface are implicitly public static final yet when I type the above statement explicitly but do not include the keyword static it compiles with no errors and can be referenced by the static way, A.a which indicates that it is still static. Is it static or not, as to me it has to be since you cannot instantiate an interface, as if you had this "instance" variable then you could therefore never

Is it ok to use 'this' in final instance variable declaration?

喜夏-厌秋 提交于 2019-12-11 18:26:16
问题 Is it OK to use the this keyword in a final instance variable declaration/initialization in Java? Like this: private final SomeClass foo = new SomeClass(this); It worked when I tried it out. And since it is not a static variable I guess it should be referring to a particular instance. But I felt unsure if it is advisable or not so therefore I wanted to ask here. Edit: The main class is an Android Activity class, and the SomeClass-instance needs this Activity as Context. 回答1: It is

Spock: mocking/stubbing void method of final class

爷,独闯天下 提交于 2019-12-11 15:37:30
问题 The mocked class here is org.apache.lucene.document.TextField . setStringValue is void . My Specification looks like this... given: ... TextField textFieldMock = GroovyMock( TextField ) // textField is a field of the ConsoleHandler class, ch is a Spy of that class ch.textField = textFieldMock // same results with or without this line: textFieldMock.setStringValue( _ ) >> null // NB I explain about this line below: textFieldMock.getClass() >> Object.class the corresponding app code looks like