I am beginner in Java. I am confused if the followings are correct or not.  The first condition is understood and is used frequently. What are the usages of others? When and how can I utilize them?  /* 1) */ Car car = new Car(); /* 2) */ Car car = new Vehicle(); /* 3) */ Vehicle car = new Car(); /* 4) */ Vehicle vehicle = new Vehicle();   Perhaps you could include examples in your answer.
I have seen this mentioned a few times and I am not clear on what it means. When and why would you do this?   I know what interfaces do, but the fact I am not clear on this makes me think I am missing out on using them correctly.   Is it just so if you were to do:  IInterface classRef = new ObjectWhatever()   You could use any class that implements IInterface? When would you need to do that? The only thing I can think of is if you have a method and you are unsure of what object will be passed except for it implementing IInterface. I cannot think how often you would need to do that.   Also, how could you write a method that takes in an object that implements an interface? Is that possible?
How to get a file's Media Type (MIME type)? I'd like to add an invisible watermark to each PDF document that I produce so that in case it leaks, I know where it leaked from. Anyone knows what would a good way for an invisible watermark be in a PDF document and how to add one? How can I launch a GameObject at a target if I am given everything except for its launch angle? I am trying to launch an object at a target, given its position, its target position, the launch speed, and the gravity.  I am following this formula from :  $$ \theta = arctan \bigg( \frac{v^2 \pm \sqrt{v^4-g(gx^2 + 2yv^2)}}{gx} \bigg) $$  I have simplified the code to the best of my ability, but I still cannot consistently hit the target.  I am only considering the taller trajectory, of the two available from the +- choice in the formula.  Does anyone know what I am doing wrong?  using UnityEngine;  public class Launcher : MonoBehaviour {     public float speed = 10.0f;      void Start()     {         Launch(GameObject.Find("Target").transform);     }      public void Launch(Transform target)     {         float angle = GetAngle(transform.position, target.position, speed, -Physics2D.gravity.y);         var forceToAdd = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * speed;         GetComponent&lt;Rigidbody2D&gt;().AddForce(forceToAdd, ForceMode2D.Impulse);     }      private float GetAngle(Vector2 origin, Vector2 destination, float speed, float gravity)     {         float angle = 0.0f;          //Labeling variables to match formula         float x = Mathf.Abs(destination.x - origin.x);         float y = Mathf.Abs(destination.y - origin.y);         float v = speed;         float g = gravity;          //Formula seen above         float valueToBeSquareRooted = Mathf.Pow(v, 4) - g * (g * Mathf.Pow(x, 2) + 2 * y * Mathf.Pow(v, 2));         if (valueToBeSquareRooted &gt;= 0)         {             angle = Mathf.Atan((Mathf.Pow(v, 2) + Mathf.Sqrt(valueToBeSquareRooted)) / g * x);         }         else         {             //Destination is out of range         }          return angle;     } } What do Android application permissions mean? When installing an application, the application lists permissions that it needs to perform its  functions.    I am creating this list of the the system defined permissions and a description of what they mean. It is a community wiki so if new permissions are added in the future they can be added to this list. When an option expires does that constitute a buy or sell A similar question recently asked about stock sales and option buys triggering wash sale rules.  If an option expires, is that considered a buy/sale ?  What I mean is: let's assume I have a call option with a target date of August 16. Now I sell the underlying stock somewhere before that (after July 16th). Does that trigger wash sale rules (if the option expires in the money, exercised by default) ?  Is an option expiring out of the money considered a sale ? I know that both can mean "inside" but what I don't have clear is whether both mean the same when talking about time. For example:   The party is in two days = The party is within two days ??   According to this link  within means a limit that can be exceeded, so I'm wondering too if say "the party is within two days max" is correct or redundant. What does \x mean in C/C++? After starting Ubuntu, I see the following lines. Should I be worried?  /dev/sda6: recovering journal /dev/sda6: clean, 355773/1835008 files, 470404803/7335680 blocks I am a newbie in linux and I don't know how to open the Ubuntu Software Center via Terminal!! Please help Newton's cradle Why, when one releases 2 balls in , two balls on the opposite side bounce out at approximately the same speed as the 1st pair, rather than one ball at higher speed, or 3 balls at lower speed? How do I split a forest tree into two trees with proper vertical alignment? \documentclass[oneside,12pt]{article} \usepackage{geometry} \usepackage{microtype} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern}  \usepackage{enumitem} \setlist[enumerate,1]{label=\bfseries\Alph*,align=left,leftmargin=*,   labelsep=1.5em} \setlist[enumerate,2]{label=\arabic*.,labelindent=1em,labelsep=1.5em,   leftmargin=*}  \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsthm} \theoremstyle{definition} \newtheorem*{sol}{Solution}  \usepackage{forest} \forestset{   ass/.append style={     before computing xy={l=\baselineskip},     no edge   },   prooftree/.style={     for tree={       child anchor=north,       parent anchor=south     }   } }  \begin{document} \subsection*{Exercises 29} \begin{enumerate} \item Use QL trees to evaluate the entailment claims (1) to (10) in Exercises   28A.   \begin{enumerate}   \item $\forall x(Fx\supset Gx)\vDash\forall x(Gx\supset Fx)$      \begin{forest}       prooftree       [$\forall x(Fx\supset Gx)$       [$\neg\forall x(Gx\supset Fx)\checkmark$,ass       [$\exists x\neg(Gx\supset Fx)\checkmark$,ass       [$\neg(Ga\supset Fa)\checkmark$,ass       [$Ga$,ass       [$\neg Fa$,ass       [$(Fa\supset Ga)\checkmark$,ass       [$\neg Fa$] [$Ga$]]]]]]]]     \end{forest}      $\neg Fa$ and $Ga$ make the premisses and the negation of conclusion true.     Thus, the entailment is invalid.   \item $\forall x(Fx\supset Gx)\vDash\forall x(\neg Gx\supset\neg Fx)$      \begin{forest}       prooftree       [$\forall x(Fx\supset Gx)$       [$\neg\forall x(\neg Gx\supset\neg Fx)\checkmark$,ass       [$\exists x\neg(\neg Gx\supset\neg Fx)\checkmark$,ass       [$\neg(\neg Ga\supset\neg Fa)\checkmark$,ass       [$\neg Ga$,ass       [$\neg\neg Fa$,ass       [$(Fa\supset Ga)\checkmark$,ass       [$\neg Fa$ [*,ass]] [$Ga$ [*,ass]]]]]]]]]     \end{forest}      Since the tree closes, the entailment is valid.   \item $\forall x\exists yLxy\vDash\forall y\exists xLyx$      \begin{forest}       prooftree       [$\forall x\exists yLxy$       [$\neg\forall y\exists xLyx\checkmark$,ass       [$\exists y\neg\exists xLyx\checkmark$,ass       [$\neg\exists xLax\checkmark$,ass       [$\forall x\neg Lax$,ass       [$\exists yLay\checkmark$,ass       [$Lab$,ass]]]]]]]     \end{forest}      \begin{forest}       prooftree       [$\neg Lab$,ass [*,ass]]     \end{forest}   \item $\forall x((Fx\wedge Gx)\supset Hx)\vDash\forall     x(Fx\supset(Gx\supset Hx))$   \item $(\forall xFx\vee\forall xGx)\vDash\forall(Fx\vee Gx)$   \item $\forall x(Fx\supset Gx),\forall x(\neg Gx\supset Hx)\vDash     \forall x(Fx\supset\neg Hx)$   \item $\exists x(Fx\wedge Gx),\forall x(\neg Hx\supset\neg Gx)\vDash     \exists x(Fx\wedge Hx)$   \item $\forall x\exists y(Fy\supset Gx)\vDash\forall y\exists x(Gx\supset     Fy)$   \item $\forall x\forall y(Lxy\supset Lyx)\vDash\forall xLxx$   \item $\forall x(\exists yLxy\supset\forall zLzx)\vDash\forall x\forall y     (Lxy\supset Lyx)$   \end{enumerate} \end{enumerate} \end{document}   Usually, I have to manually split a forest tree into two to emulate page breaking in a forest tree. However, the second tree doesn't vertically align with the first as in the picture below. How can I vertically align them together? @cfr Closed-form of $\int_0^1 \operatorname{Li}_p(x) \, dx$ I was doing a package removal with apt-get remove but then realized I should have done a --purge along with it to remove the configuration files.  Can I remove the packages configuration files easily or do I need to reinstall the package and then remove with a --purge? Simpler proof - Non atomic measures Suppose that $(X,\mathcal{E},\mu)$ is a non-atomic finite measure space (i.e. for every $E \in \mathcal{E}$ with $\mu(E)&gt;0$ there exists $F \subset E$ measurable such that $0&lt;\mu(F) &lt;\mu(E)$.)  a) Prove that for every $ \varepsilon &gt;0$ there is a finite partition of $X$ in measurable subsets $X_1,..,X_n$ such that $\mu(X_i)\leq \varepsilon$.  b) Prove that for every $\alpha \in [0,\mu(X)]$ there exists $E \in \mathcal{E}$ with $\mu(E)=\alpha$.    I guess that a) is given to prove b) more easily. I have the following idea of solution for a) (inspired from , which proves b)  )  Denote  $$ \Gamma = \{ (X_1,..,X_n) : n &gt;&gt; \mu(X)/\varepsilon, X_i \text{ are disjoint }, \mu(X_i)\leq \varepsilon \}$$ ordered by componentwise inclusion. Totally ordered parts $(Y_\alpha)$ of $\Gamma$ have an upper bound element $(\bigcup Y_\alpha^i)_{i=1}^n$ which is still in $\Gamma$.   By Zorn's lemma $\Gamma$ has maximal elements. If a maximal $(X_1..X_n)$ element is not a partition, then we can replace it with something better, of the form $(X_1,..,X_n\cup A)$ where $A \subset X \setminus (X_1 \cup..\cup X_n)$ and $\mu(A)&gt;0$.     My questions are:  1) Is my solution of a) correct? I feel that the part with the upper bound element may not work, since there might be noncountable unions.  2) What is a simpler solution of a)? So basically , we all know the direction outside the magnet its from NORTH to SOUTH. but what i don't understand is that what is the direction inside is it the same ?? Wikipedia lists the following pseudocode for HMAC:  function hmac (key, message)     if (length(key) &gt; blocksize) then         key = hash(key) // keys longer than blocksize are shortened     end if     if (length(key) &lt; blocksize) then         // keys shorter than blocksize are zero-padded ('∥' is concatenation)          key = key ∥ [0x00 * (blocksize - length(key))]      end if      // Where blocksize is that of the underlying hash function        o_key_pad = [0x5c * blocksize] ⊕ key      // Where ⊕ is exclusive or (XOR)     i_key_pad = [0x36 * blocksize] ⊕ key       // Where '∥' is concatenation        return hash(o_key_pad ∥ hash(i_key_pad ∥ message))  end function   Why are they there?  How were they chosen?  It seems to me that  $hash(key + hash(message))$ (where + is concatenation) would suffice.    Obviously I'm missing something.  What is it? How to derive this version of variance formula A probably very easy computational question, but I don't really understand how it's done:  I try to compute the point estimates of a normal distribution as $N \sim (\beta, \sigma)$. Using the method of moments, we get:  $$\frac{1}{n} \sum_{i=1}^{n} X_{i} = \hat{\beta}$$  $$\frac{1}{n} \sum_{i=1}^{n} X_{i}^{2} = \hat{\sigma}^2 + \hat{\beta}^2$$  Solving the two equations for the two parameters, we get:  $$\hat{\beta} = \overline{X} $$   and   $$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^{n} (X_{i} - \overline{X}_n)^2 $$  My question is: How do we get to the term of $\hat{\sigma}^2$? If I try to compute it, I get:  $$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^{n} X_{i}^2 - (\frac{1}{n} \sum_{i=1}^{n} X_{i} )^2 $$  Can someone show me how to simplify the last term to what is stated above and what "rule" or law" is used there? Since it is used so often, I really wanna understand this. Assumptions of linear regression I'm trying to write a blog post which includes a code segment inside a &lt;pre&gt; tag. The code segment includes a generic type and uses &lt;&gt; to define that type. This is what the segment looks like:  &lt;pre&gt;     PrimeCalc calc = new PrimeCalc();     Func&lt;int, int&gt; del = calc.GetNextPrime; &lt;/pre&gt;   The resulting HTML removes the &lt;&gt; and ends up like this:  PrimeCalc calc = new PrimeCalc(); Func del = calc.GetNextPrime;   How do I escape the &lt;&gt; so they show up in the HTML? Can someone help with an explanation and some references, in order to understand the nature of return pulses within a LiDAR system.