Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The type inference is available in IntelliJ, possibly other IDEs as well. You can write an expression (or use an existing one) and select "Introduce Field/Local variable/Constant" etc and it will give you some type options inferred and some suggested names. If the expression appears more than once it gives you the option to replace all occurrences. e.g. say I have a string I want to turn into a parameter</p> <pre><code>myMethod(); public void myMethod() { "/tmp/20101112/data.file" } </code></pre> <p>I select the date portion and &lt;ctrl>+&lt;alt>+P and it suggests an int type to add as a parameter. It will inline this date into all callers.</p> <pre><code>myMethod(20101112); public void myMethod(int date) { "/tmp/"+date+"/data.file" } </code></pre> <p>I place "new FileInputStream(" at the start and introduce a Local Variable. &lt;ctrl>+&lt;alt>+V</p> <pre><code> FileInputStream fileInputStream = new FileInputStream("/tmp/"+date+"/data.file"); </code></pre> <p>It highlights that this can throw an exception which I can auto fix a number of ways. I select &lt;alt>+&lt;enter> and add the exception to the throws clause of the method.</p> <pre><code>myMethod(20101112); public void myMethod(int date) throws FileNotFoundException { FileInputStream fileInputStream = new FileInputStream("/tmp/"+date+"/data.file"); </code></pre> <p>IMHO, it makes much more sense to have the IDE do the work as it can do much more interactively than the compiler and you can see explicitly what your types become.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload