老紫竹JAVA基础培训(1)认识HelloWorld程序

深入解析“PROJ: proj_create_from_database: Cannot find proj.db”错误:从环境配置到打包实战 本文深入解析了“PROJ: proj_create_from_database: Cannot find proj.db”错误的根源与解决方案,涵盖环境配置、PyInstaller打包及跨平台兼容性处理。通过详细分析PROJ库路径问题及GDAL依赖关系,提供动态路径设置、资源文件打包等实战技巧,帮助开发者高效解决地理数据处理中的常见错误。 阅读详情
  先看代码:
E:/javalession/base/src/lession1/HelloWorld.java



  1. // package 影响到你的类存储目录和访问方式
  2. package lession1;

  3. // public 要求你的文件名必须和类名相同
  4. // 一个文件里最多有一个public类,允许没有
  5. public class HelloWorld {

  6.   // 这个是应用程序的入口,我们以能运行为标准讨论
  7.   // 必须是public的
  8.   // 必须是 static 的
  9.   // 可以用 final 修饰符
  10.   // 返回值必须是 void
  11.   // 参数必须是字符串数组,String args[] 这样写也可以
  12.   // args纯粹是习惯,可以用任何变量的名字
  13.   // main方法里允许抛出异常,我在后面给一个修改后的代码
  14.   public static void main(String[] args) {
  15.     // System类属于java.lang,全称是java.lang.System
  16.     // java.lang 这个包是唯一可以不用import的,可以直接使用
  17.     // out是标准输出
  18.     // println 是在标准输出打印字符串,且末尾换行
  19.     // 参数是一个字符串
  20.     System.out.println("Hello World!");
  21.   }
  22. }


注意:
  • 一定要有一个lession1目录,然后把HelloWord.java保存在里面。
  • 注意文件名区分大小写的,一定要是HelloWorld.java

请尝试如下的情况对代码的影响, 记得每次尝试后,恢复原始版本哦
  • 去掉类的public 然后编译
  • 将类名HelloWorld改成 helloWorld 然后编译看看
  • 把文件名改成 helloWorld.java 然后编译看看
  • 把 main方法的 public 去掉,然后编译,然后运行看看
  • 把 main方法的 static 去掉,然后编译,然后运行看看
  • 把 main方法的 main 改成 mainABC ,然后编译,然后运行看看
  • 把 main方法的 String[] 参数类型改成 String,然后编译,然后运行看看
  • 把 main方法的 String[] args 改成 String args[] ,然后编译,然后运行看看
好了,今天这第一课就到这里。程序虽然很短,但东西还是很多的。都是一些基本概念。

附上带抛出异常的main代码,这个在调试程序时为了省事,偷懒,我经常这么做
  1. public final static void main(String[] args) throws IOException,Exception
完整的项目截屏



更多的 JAVA基础系列课程 请看这里,如果我修正了里面的全部错误,将逐个转发到csdn.

SocraticLM: Exploring Socratic Personalized Teaching with Large Language Models 大型语言模型(LLM)被认为是推进智能教育的一项关键技术,因为它们展示了深入理解教学场景和为学生提供个性化指导的潜力。然而,当前个性化教学中基于LLM的应用主要遵循“问答”范式,学生被动地获得答案和解释。在本文中,我们提出了苏格拉底式教学模式(SocraticLM ),它实现了一种苏格拉底式的“发人深省”的教学范式,实现了真正的课堂教师的角色,让学生积极参与到真正掌握解决问题所需的思考过程中。 阅读详情

相关推荐

Abaqus复合材料层合板仿真

由于复合材料的损伤失效问题过于复杂,解析方法受到数学工具的限制难以实现,而实验也需要高昂的费用和时间成本难以广泛应用,Abaqus针对复合材料提供了专业的建模工具和损伤分析理论来模拟复合材料层合板在各种工况下的失效行为。

JXHXHL的博客 2545

CSDN JAVA版主老紫竹的一段模拟买火车票的多线程代码(转)

class tt { public static void main(String[] args) { Runnable st = new SellThread(); new Thread(st).start(); new Thread(st).start(); new Thread(st).start();

不随黄叶舞秋风 3522

Freemarker整合poi导出带有图片的Excel教程

Freemarker整合poi导出带有图片的Excel教程 https://blog.csdn.net/x541211190/article/details/105675771根据此人博客可完成此功能,但原文中有一处错误需要纠正,当单元格合并时,计算起始单元格有错误。 源代码: /** * 构造合并单元格集合 * * @param createRowIndex: * @param cellRangeAddresses: * @param startIndex: * @param c

weixin_39403349的博客 1005

java_lesson

1.JAVA有下标检查;2.String s;  s为String类的一个引用(String s=new String("a string"));  所有的对象都必须new出来;3.所有方法都必须再类中;赋值实际上将句柄从一个地方复制到另一个地方;  public class Test{ int i=0; public static void main(String[] args) {  Test

我的蓝天我的白云... 707

【在 WSL2 GUI 中使用 pulseaudio 播放声音】

最近在搞一个Linux项目,由于WSL2中需要用到声音外放,无奈只能潜心研究。后来就使用了一种折中的方式替代,那就是pulseaudio。目前来讲WSL2对硬件外设的支持还是不太友好,关于USB的支持我之前在其他文章中已经论述过了,这里不讨论。1、Windows11别忘记打开声音2、可能有一定延迟,因为是通过网络传输的。3、效果的话只能见仁见智了,如果不能满足要求就安装一个实实在在的Ubuntu吧!

jiexijihe945的博客 4536

UWB 多传感器通信的纳秒无线位置和时钟同步方法

利用UWB高精度的特点,实现多节点下的无线时钟同步和定位。通过优化硬件架构,减少不确定延迟的影响,系统可以提供纳秒级时钟同步消息

DT程序员的博客 1338

老紫竹Java EE培训教程(2) - 认识JSP的HelloWorld

原文地址:http://www.java2000.net/p12520我们先看第一个HellWorld程序,别看代码多,我只是顺便介绍一下几种输出HelloWorld!的方式而已。源代码如下"UTF-8"%>  /**   *  老紫竹JavaEE培训教程(2)-认识JSP的HelloWorld   */%> // 这是单行注释%>Hello World!"Hello World!"%> 

老紫竹的专栏 3488

从 ABAP 视角看 JSON :7.40 版本带来的那些改变

摘要:ABAP 对 JSON 的原生支持 随着企业系统与外部 API 的交互增多,ABAP 从 NetWeaver 7.40 开始原生支持 JSON 格式。通过复用现有 XML 基础设施,ABAP 团队引入 JSON-XML 概念,使用 sXML Library 和 IF_SXML=>CO_XT_JSON 常量处理 JSON 数据。开发人员可通过 CALL TRANSFORMATION 语句实现 ABAP 数据与 JSON 的双向转换,大幅简化了与外部系统的数据交互。这种标准化的 JSON 处理方式提

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 183

老紫竹JAVA提高教程-System.arraycopy方法的使用

 不废话,直接看代码就全清楚了。里面 // 后面的是运行的结果 import java.util.Arrays;/** * 老紫竹JAVA提高教程 - System.arraycopy方法的使用。 * * 从指定源数组中复制一个数组,复制从指定的位置开始, * 到目标数组的指定位置结束 * * @author 老紫竹的家(java2000.net,laoz

老紫竹的专栏 4万+

手把手教你学Simulink——基于电机驱动系统的场景实例:轮毂电机在电动汽车中的分布式驱动控制仿真

本文详细介绍了基于MATLAB/Simulink和Simscape Electrical的电动汽车轮毂电机分布式驱动控制系统建模方法。内容包括系统结构设计(轮毂电机、逆变器、控制器等模块)、完整的建模过程(从基础模块导入到车辆动力学建模)、控制器设计与转矩分配策略实现,以及仿真参数设置与结果分析。通过仿真验证了该分布式驱动系统在速度跟踪、转弯性能等方面的优异表现,为电动汽车驱动系统的研究与开发提供了有效的仿真验证平台。文中还提供了相关代码示例和资料推荐,是学习Simulink电机控制系统建模的实用指南。

MHD0815的博客 4916

BLDC&PMSM电机控制器硬件设计工程(十)72V 2kW电机控制器原理图工程及库文件

电机控制器基本需求:接口类型;MCU平台;通信接口;供电;信号采集;信号输出;功率;EMC或者认证需求。

小幽余生不加糖 275

老紫竹JAVA提高教程-信号量(Semaphore)在生产者和消费者模式的使用

 Semaphore 信号量,就是一个允许实现设置好的令牌。也许有1个,也许有10个或更多。谁拿到令牌(acquire)就可以去执行了,如果没有令牌则需要等待。执行完毕,一定要归还(release)令牌,否则令牌会被很快用光,别的线程就无法获得令牌而执行下去了。 请仔细体会里面关于仓库的处理,1 是如何保证入库时,如果仓库满就等待,2 出库时,如果仓库无货就等待的。3

老紫竹的专栏 1万+

全桥 LLC 谐振变换器详细解析:结构 + 控制 + 工作原理全搞懂!

在现代高效率电源系统中,LLC 谐振变换器🔥早已成为降损利器。尤其是全桥 LLC 拓扑结构,由于其在、副边整流管的 ZCS(零电流关断),再加上优秀的效率表现,已经成为服务器电源、电动汽车 OBC、光伏逆变等场景的首选。那么,全桥 LLC 到底长啥样?它的控制方式是怎么回事?具体工作波形又是如何呢?今天我们就来一篇讲清楚、讲透彻的文章!🚗💨。

weixin_43199439的博客 3559

老紫竹JAVA基础培训(9),控制台键盘输入(System.in)

    // 这段代码用来读取键盘输入的整数    // 请注意,你需要输入合法的整数    int age = Integer.MIN_VALUE;    while (age == Integer.MIN_VALUE) {      System.out.print("请输入你的年龄:");      try {        age = scan.nextInt();      } catc

老紫竹的专栏 7254

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

老紫竹B/S文件管理系统(webfile 0.1版)发布

 老紫竹B/S文件管理系统=================功能介绍-------        1 全部用JSP编写        2 文集列表,支持页面排序(点击标题)        3 编辑小于指定大小的文件(默认1M)        4 上传文件        5 下载文件        安装配置-------        1 标准的W

老紫竹的专栏 5900

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

跟老紫竹学Java - JAVA自测题栏目正式上线,来测测你的Java功力到底如何!

题目基本上比较基础,但有一些如果不认真还是不行的。栏目地址:http://www.java2000.net/selftest/ 题目在不断的更新中。

老紫竹的专栏 5696

老紫竹JAVA提高教程(2)-认识Set集合之HashSet

原文地址:http://www.java2000.net/p11767 集合在Java里面的作用非凡,我们常用的有Set,List和Map三种,我们先熟悉一下Set,特别是HashSet的使用package collection.lession2;import java.util.HashSet;import java.util.Set;/** * 老紫竹JAVA提高教程(2)-认识Set集合之H

老紫竹的专栏 5567

老紫竹提高教程 - Java代理服务器和NTLM认证的使用

机器在局域网里面,使用了NTLM的认证,不能直接访问外网,本机也没有安装 ISA 的Client这个代码包含了2部分1 如果你使用代理服务器,那么只需要设置Properties部分就行了2 如果你使用NTML,那么用那个Authenticator 就可以了。import java.net.Authenticator;import java.net.PasswordAuthe

老紫竹的专栏 5078

跟老紫竹学Java-图书销售系统

原文地址:http://www.java2000.net/f398博客链接如下跟老紫竹学Java-图书销售系统-项目下载跟老紫竹学Java-图书销售系统-POJO类跟老紫竹学Java-图书销售系统-辅助类和配置文件跟老紫竹学Java-图书销售系统-数据库结构跟老紫竹学Java-图书销售系统-服务接口和实现跟老紫竹学Java-图书销售系统-主页,注册,登录,退出登录等常规页面跟老紫竹学Java-图书

老紫竹的专栏 4921

跟老紫竹学Java-留言板项目

本项目将提供一个可以注册,发言和回复的留言板。提供自己书写的分页功能。 提供JDBC和Hibernate两个后台版本的实现提供 JSTL和JSP的两个前台版本的实现数据库结构和POJO http://blog.csdn.net/java2000_net/archive/2008/07/20/2680146.aspx 服务接口 http://blog.csdn.net/java2

老紫竹的专栏 4505

老紫竹JAVA提高教程(4)-认识Set集合之TreeSet

原文地址:http://www.java2000.net/p11837TreeSet 是用来进行集合排序的,请注意他和LinkedHashSet的区别。TreeSet是按照一定的规则,将加入到集合里面的数据进行排序,而LinkedHashSet是严格按照你放入集合的顺序进行使用。先看源代码package collection.lession4;import java.util.Arra

老紫竹的专栏 4235

老紫竹JAVA提高教程(3)-认识Set集合之LinkedHashSet

 原文地址:http://www.java2000.net/p11794有序的集合,就是LinkedList,内部通过双向链表实现,LinkedHashMap为基础。package collection.lession3;import java.util.Arrays;import java.util.HashSet;import java.util.LinkedHashSet;import 

老紫竹的专栏 4146

老紫竹JAVA基础培训(6),For循环语句的使用

原文:http://www.java2000.net/p11512在所有的循环中,最常用的就是for了,另外2个 while和do..while我基本不用。所以我这里就把for循环重点介绍一下。package lession6;/** * 老紫竹JAVA基础培训(6),For循环语句的使用。 *  * @author 老紫竹 JAVA世纪网(java2000.net) *  */public cl

老紫竹的专栏 3984

跟老紫竹学Java-留言板-回复页面(JSP)

 原文地址:http://www.java2000.net/viewthread.jsp?tid=7342以下是图片,不是文字 <!--google_ad_client = "pub-2908059660288034";/* 728x90,首页中间 创建于 08-8-14 */google_ad_slot = "5903610560";google_ad_wi

老紫竹的专栏 3858

跟老紫竹学Java的说明

 考虑再三,自己最熟悉的还是这么多年使用Java在服务器端和Web方面的编程经验了。决定重新整理自己这么多年的经验,看看到底自己都会啥?考虑到实际情况,将采用虚拟项目的形式,根据项目的大小,从项目的分析设计到开发,记录整个过程。项目范围从小芝麻到大西瓜。每个项目都希望得到大家的反馈,以便不断完善,让不同的朋友都能从对应的项目中得到帮助,哪怕一点点也好。当让,更希望更多的人加入项目的开发

老紫竹的专栏 3781
上一篇: JDK6的新API使用默认关联程序打开文件
下一篇: 为什么Thread.stop会过期?一段引起同步异常问题的代码样例
老紫竹
博客等级 码龄19年 1万+粉丝 1252原创
评论 10
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值