<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Der Informatikblog &#187; nextInt</title>
	<atom:link href="http://www.informatik-blog.net/tag/nextint/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.informatik-blog.net</link>
	<description>Informatik &#38; Co.</description>
	<lastBuildDate>Mon, 19 Dec 2011 13:01:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Zufallszahlen erzeugen</title>
		<link>http://www.informatik-blog.net/2009/01/21/zufallszahlen-erzeugen/</link>
		<comments>http://www.informatik-blog.net/2009/01/21/zufallszahlen-erzeugen/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 17:51:31 +0000</pubDate>
		<dc:creator>Emanuel</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[nextBoolean]]></category>
		<category><![CDATA[nextDouble]]></category>
		<category><![CDATA[nextInt]]></category>
		<category><![CDATA[nextLong]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://www.informatik-blog.net/?p=19</guid>
		<description><![CDATA[In Java ist es möglich Zufahlsausgaben mit den Datentypen int, long, double und boolean zu erstellen. Dies erfolgt mit der Klasse Java.util.Random. Bitte beachtet, dass ein Zufahlsgenerieren zurückerechnet werden kann. Sollte ein tatsächlicher Zufall entstehen, muss mittels ticks, etc. zufälle generiert werden. Hier der Code, für das erstellen von einem Zufalls Long, Integer, Double und [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>In Java ist es möglich Zufahlsausgaben mit den Datentypen <strong>int, long, double und boolean</strong> zu erstellen. Dies erfolgt mit der Klasse Java.util.Random. Bitte beachtet, dass ein Zufahlsgenerieren zurückerechnet werden kann. Sollte ein tatsächlicher Zufall entstehen, muss mittels ticks, etc. zufälle generiert werden. Hier der Code, für das erstellen von einem Zufalls Long, Integer, Double und boolean.<br />
Die Ausgabe bei diesem Beispiel lautet zum beispiel: <span id="more-19"></span></p>
<p><strong>double:0.1821161520072201<br />
boolean:false<br />
lr:6101892338103925785<br />
ir:50</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tutorialstrings</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Random</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author li
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @param args the command line arguments
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003399;">Random</span> r <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">double</span> dr <span style="color: #339933;">=</span> r.<span style="color: #006633;">nextDouble</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">boolean</span> br <span style="color: #339933;">=</span> r.<span style="color: #006633;">nextBoolean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">long</span> lr <span style="color: #339933;">=</span> r.<span style="color: #006633;">nextLong</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> ir <span style="color: #339933;">=</span> r.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;double:&quot;</span> <span style="color: #339933;">+</span> dr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;boolean:&quot;</span> <span style="color: #339933;">+</span> br<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lr:&quot;</span> <span style="color: #339933;">+</span> lr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ir:&quot;</span> <span style="color: #339933;">+</span> ir<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.informatik-blog.net/2009/01/21/zufallszahlen-erzeugen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lottozahlen generieren</title>
		<link>http://www.informatik-blog.net/2009/01/21/lottozahlen-generieren/</link>
		<comments>http://www.informatik-blog.net/2009/01/21/lottozahlen-generieren/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 17:49:37 +0000</pubDate>
		<dc:creator>Emanuel</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[nextInt]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[TreeSet]]></category>

		<guid isPermaLink="false">http://www.informatik-blog.net/?p=17</guid>
		<description><![CDATA[Oft denkt man sich, dass es wesentlich sinnvoller ist Lottozahlen zu generieren, als sie selbst anzukreuzen. Das ankreuzen kostet nicht nur Zeit, sondern man steht auch oft davor und weiß nicht welche zahl man nehmen soll. Hierfür kann man diese Zahlen am besten per Java generieren. Dies spart nicht nur Zeit, sondern es ist auch [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<p>Oft denkt man sich, dass es wesentlich sinnvoller ist Lottozahlen zu generieren, als sie selbst anzukreuzen. Das ankreuzen kostet nicht nur Zeit, sondern man steht auch oft davor und weiß nicht welche zahl man nehmen soll. Hierfür kann man diese Zahlen am besten per Java generieren. Dies spart nicht nur Zeit, sondern es ist auch Witzig anzusehen, welche zufallsergebnisse raus kommen. Die Ausgabe unterscheidet sich natürlich bei jedem aufruf, könnte aber, wie z.b bei mir folgende sein:<br />
<span id="more-17"></span><br />
<strong>2<br />
6<br />
8<br />
14<br />
24<br />
40</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tutorialstrings</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Random</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.TreeSet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author li
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @param args the command line arguments
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Lottozahlen!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">TreeSet</span> randomNumbers <span style="color: #339933;">=</span> uniqueRandoms<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">49</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> e <span style="color: #339933;">:</span> randomNumbers<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">TreeSet</span> uniqueRandoms<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> size, <span style="color: #000066; font-weight: bold;">int</span> min, <span style="color: #000066; font-weight: bold;">int</span> max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">TreeSet</span> numbers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TreeSet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Random</span> generator <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> n<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>size <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> max <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">-</span> min<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;keine eindeutigen Zahlen&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>size <span style="color: #339933;">==</span> max <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">-</span> min<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> min<span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> max<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                numbers.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>numbers.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> size<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                n <span style="color: #339933;">=</span> min <span style="color: #339933;">+</span> generator.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span>max <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">-</span> min<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                numbers.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> numbers<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.informatik-blog.net/2009/01/21/lottozahlen-generieren/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

