snipt

Ctrl+h for KB shortcuts

Java

java helloworld

1
2
3
4
5
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}
https://snipt.net/embed/0ca060712739cbfa592938b42e2d7853/
/raw/0ca060712739cbfa592938b42e2d7853/
0ca060712739cbfa592938b42e2d7853
java
Java
6
2019-06-24T01:35:37
True
False
False
/api/public/snipt/3461/
java-helloworld
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">class</span> <span class="nc">HelloWorldApp</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&quot;Hello World!&quot;</span><span class="o">);</span> <span class="c1">// Display the string.</span> </span><span id="L-4"><a name="L-4"></a> <span class="o">}</span> </span><span id="L-5"><a name="L-5"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
helloworld, java

Java

Text input in a string

1
2
3
4
5
6
7
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

String word = new String();
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
word = input.readLine();
https://snipt.net/embed/6af814de7ddd8a3ea74948fee1874905/
/raw/6af814de7ddd8a3ea74948fee1874905/
6af814de7ddd8a3ea74948fee1874905
java
Java
7
2019-06-24T05:30:02
True
False
False
/api/public/snipt/1895/
input-di-testo-in-una-stringa
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kn">import</span> <span class="nn">java.io.BufferedReader</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a><span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="o">;</span> </span><span id="L-3"><a name="L-3"></a><span class="kn">import</span> <span class="nn">java.io.InputStreamReader</span><span class="o">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="n">String</span> <span class="n">word</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">();</span> </span><span id="L-6"><a name="L-6"></a><span class="n">BufferedReader</span> <span class="n">input</span> <span class="o">=</span> <span class="k">new</span> <span class="n">BufferedReader</span><span class="o">(</span><span class="k">new</span> <span class="n">InputStreamReader</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">in</span><span class="o">));</span> </span><span id="L-7"><a name="L-7"></a><span class="n">word</span> <span class="o">=</span> <span class="n">input</span><span class="o">.</span><span class="na">readLine</span><span class="o">();</span> </span></pre></div> </td></tr></table>
input, java

Text only

Options to solve Permgen problem in Tomcat

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
https://snipt.net/embed/38923b182ca8eed40b7f657d69bc1622/
/raw/38923b182ca8eed40b7f657d69bc1622/
38923b182ca8eed40b7f657d69bc1622
text
Text only
2
2019-06-23T00:01:01
True
False
False
/api/public/snipt/1555/
options-to-solve-permgen-problem-in-tomcat
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled </span></pre></div> </td></tr></table>
java, permgen, tomcat

Java

Hello World in Java

1
2
3
4
5
6
7
// Hello World in Java

class HelloWorld {
  static public void main( String args[] ) {
    System.out.println( "Hello World!" );
  }
}
https://snipt.net/embed/4e97a39a7cd6d5558d41bb0fe6bbb073/
/raw/4e97a39a7cd6d5558d41bb0fe6bbb073/
4e97a39a7cd6d5558d41bb0fe6bbb073
java
Java
8
2019-06-24T06:47:17
True
False
False
/api/public/snipt/1477/
hello-world-in-java
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// Hello World in Java</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="kd">class</span> <span class="nc">HelloWorld</span> <span class="o">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="kd">static</span> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span> <span class="n">String</span> <span class="n">args</span><span class="o">[]</span> <span class="o">)</span> <span class="o">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span> <span class="s">&quot;Hello World!&quot;</span> <span class="o">);</span> </span><span id="L-6"><a name="L-6"></a> <span class="o">}</span> </span><span id="L-7"><a name="L-7"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
hello, in, java, world

Java

Java ForEach Loop

1
2
3
for(ObjectName object: objectList) {
   // Code Here
}
https://snipt.net/embed/6e40439d3cc5e9b4e6055ff736433bc3/
/raw/6e40439d3cc5e9b4e6055ff736433bc3/
6e40439d3cc5e9b4e6055ff736433bc3
java
Java
3
2019-06-24T07:05:27
True
False
False
/api/public/snipt/891/
java-foreach-loop
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">for</span><span class="o">(</span><span class="n">ObjectName</span> <span class="n">object</span><span class="o">:</span> <span class="n">objectList</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">// Code Here</span> </span><span id="L-3"><a name="L-3"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
foreach, java, loop