AI玩具

茶山项目


Java语言筑基期

<h1>🌟小学生也能学会的Java入门指南</h1> <p><strong>用游戏闯关的方式,边玩边学编程!</strong> </p> <hr /> <h2>第一步:不用安装软件,直接开玩!</h2> <p><strong>推荐工具</strong>:在线编程游乐场 🎮 </p> <ol> <li>打开网站👉 <a href="https://www.onlinegdb.com/online_java_compiler">OnlineGDB Java编译器</a> </li> <li>点击左上角选择 <strong>Java</strong> 语言 </li> <li> <p>删除默认代码,把这段<strong>魔法咒语</strong>贴进去: </p> <pre><code class="language-java">public class Main { public static void main(String[] args) throws InterruptedException { System.out.println(&amp;quot;✨欢迎来到Java魔法世界!✨&amp;quot;); System.out.println(&amp;quot;(≧∇≦)ノ 你的冒险开始啦~&amp;quot;); // 让文字像动画一样跳出来 for (int i=0; i&amp;lt;3; i++) { Thread.sleep(1000); // 等待1秒 System.out.println(&amp;quot;加载中...&amp;quot; + (i+1)); } System.out.println(&amp;quot;🎉恭喜!你召唤出了第一段代码!&amp;quot;); } }</code></pre> </li> <li>点击绿色 <strong>Run</strong> 按钮,看神奇效果! </li> </ol> <hr /> <h2>第二步:认识代码里的“积木块”</h2> <h3>1. <strong>会说话的代码</strong></h3> <pre><code class="language-java">System.out.println(&amp;quot;这里写你想说的话&amp;quot;); </code></pre> <p>• 就像给电脑下命令:“把这句话显示在屏幕上!”<br /> • 试试把<code>&amp;quot;这里写你想说的话&amp;quot;</code>改成<code>&amp;quot;我是编程小超人!&amp;quot;</code>再运行 </p> <h3>2. <strong>会变魔术的数字盒</strong>(变量)</h3> <pre><code class="language-java">int 我的积分 = 100; // 创建叫“我的积分”的盒子,存数字100 System.out.println(&amp;quot;当前积分:&amp;quot; + 我的积分); </code></pre> <p>• <code>int</code> 是“数字盒”的标签<br /> • 可以玩加减法:<code>我的积分 = 我的积分 + 50;</code> </p> <hr /> <h2>第三步:编程版“脑筋急转弯”</h2> <h3>1. <strong>选择题(if语句)</strong></h3> <pre><code class="language-java">int 考试成绩 = 85; if (考试成绩 &amp;gt;= 90) { System.out.println(&amp;quot;🎮奖励玩1小时游戏!&amp;quot;); } else if (考试成绩 &amp;gt;= 60) { System.out.println(&amp;quot;📚再做一套练习题吧~&amp;quot;); } else { System.out.println(&amp;quot;💪明天继续努力!&amp;quot;); }</code></pre> <p><strong>小实验</strong>:把<code>85</code>改成<code>95</code>或<code>55</code>看结果变化 </p> <h3>2. <strong>重复魔法(循环)</strong></h3> <pre><code class="language-java">// 让电脑帮你写10遍罚抄 for (int 次数=1; 次数&amp;lt;=10; 次数++) { System.out.println(次数 + &amp;quot;. 我再也不上课偷吃零食了&amp;quot;); }</code></pre> <p><strong>小彩蛋</strong>:把<code>10</code>改成<code>100</code>试试(别真让老师看到!) </p> <hr /> <h2>第四步:创造你的第一个小游戏</h2> <h3>🎲 <strong>猜数字游戏</strong></h3> <pre><code class="language-java">import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner 扫描仪 = new Scanner(System.in); int 神秘数字 = 7; // 藏在电脑里的数字 System.out.println(&amp;quot;猜猜我心里想的数字(1-10):&amp;quot;); int 你的答案 = 扫描仪.nextInt(); if (你的答案 == 神秘数字) { System.out.println(&amp;quot;🎇哇!你是读心术大师!&amp;quot;); } else { System.out.println(&amp;quot;💦差一点!正确答案是&amp;quot; + 神秘数字); } } }</code></pre> <p><strong>玩法升级</strong>:把<code>神秘数字</code>改成<code>(int)(Math.random()*10+1)</code>就能随机生成数字啦! </p> <hr /> <h2>✨小贴士✨</h2> <ol> <li><strong>代码就像乐高</strong>:先模仿,再组合创新 </li> <li><strong>错误是好朋友</strong>:如果运行报错,检查是否用了中文标点(要用英文符号!) </li> <li><strong>每天5分钟</strong>:在<a href="https://codegym.cc/">CodeGym</a>玩小游戏学编程 </li> </ol> <p>&gt; <strong>老师的话</strong>:编程就像学骑自行车,刚开始会摔倒,多试几次就能自由驰骋啦!下次可以尝试用Java做计算器、画星星图案哦~ 🌟</p>

页面列表

ITEM_HTML