扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
import java.applet.Applet;
五家渠ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
public class DrawString extends Applet {
public void paint(Graphics g)
{
g.setFont(new Font("宋体",Font.BOLD,36));
g.setColor(Color.green);
g.drawString("这是一个Java Applet程序",5,30);
g.setColor(Color.red);
g.drawString("欢迎学习Java",5,80);
}
}
首先创建一个连接工厂import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;public class ConnectionFactory {
private Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
public ConnectionFactory() {
super();
1------------------------------------------------------------------------------
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException{
Scanner scan = new Scanner(System.in);
System.out.println("输入一个整数:");
int num = scan.nextInt();
char[] numChar = Integer.toString(num).toCharArray();
for(int i = 0;inumChar.length; i++) {
System.out.println(numChar[i]);
}
}
}
2-----------------------------------------------------
public class Text2 {
public static void main(String[] args) {
int j = 0, k = 0;
for (int i = 1 ; i = 100; i++) {
if (i % 2 == 0) {
j += i ;
} else {
k += i;
}
}
System.out.println("偶数和为:" + j);
System.out.println("奇数和为:" + k);
}
}
3------------------------------------------------------------------------
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner san = new Scanner(System.in);
int aint = 0;
System.out.print("请输入一个整数: ");
aint = san.nextInt();
System.out.println(aint + "的二进制表示为: " + Integer.toBinaryString(aint));
}
}
4--------------------------------------------------------------------------------
public class text {
public static void main(String args[]) {
text t = new text();
System.out.print(t.sum());
}
public int sum(){
int a = 0;
for(int i=1;i=10;i++){
int b = 1;
for (int j = 1; j =i; j++) {
b = b*j;
}
a=a+b;
}
return a;
}
}
4.2----------------------------------------------------------
import java.io.*;
public class jiecheng
{
public static long fac(int n)
{long res=1;
for(int k=2;k=n;k++)
res*=k;
return res;}
public static void main(String args[]) throws IOException
{long sum=0;int i=1,n=20;
for(i=1;i=n;i++)
sum+=fac(i);
System.out.println("前"+n+"项阶乘的为:"+sum);
}
}
5--------------------------------------------------------------------------
public class Dy3 {
public static void main(String[] args) {
int sum = 0 ;//素数和
String s="";//素数
boolean y = true ;
for(int i = 100 ; i = 1000 ; i++){
y=true;//为每个数初始化y为真
for(int j = 2 ; j i ; j++){
if(i % j == 0){
y = false;//被除了1和本身以外的数整除为false
break;
}
}
if(y)
{
s+=i+" ";
sum+=i;
}
}
System.out.println("素数为:"+s);
System.out.println("素数和为:"+sum);
}
}
6--------------------------------------------------------------
public class Demo{
public static void main(String args[]){
int i,j;
for(i=1;i10;i++)
{
for(j=1;j=i;j++) //此处如果想输入完全的9x9则将j=i改为j10
{
System.out.print(j+"*"+i+"="+i*j+"\t");
}
System.out.println();
}
}
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流