java代码gdb,java代码例子

Java简单问题求编程

public class Demo {

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及成都酒店设计等,在网站建设公司全网营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

public static void main(String[] args) {

Demo demo = new Demo();

demo.question1();

demo.question2();

demo.question3();

demo.question4();

demo.question5();

demo.question6();

}

private void question1() {

System.out.println("Q1:");

Scanner scanner = new Scanner(System.in);

System.out.println("请输入第一个数:");

int num1 = scanner.nextInt();

System.out.println("请输入第二个数:");

int num2 = scanner.nextInt();

System.out.println("和: " + (num1 + num2));

System.out.println("差: " + (num1 - num2));

System.out.println("积: " + (num1 * num2));

String value = String.valueOf((double) num1 / num2);

System.out.println("商: " + (value.substring(0, value.indexOf("."))));

System.out.println("余数: " + (num1 % num2));

}

private void question2() {

System.out.println("Q2:");

Scanner scanner = new Scanner(System.in);

System.out.println("请输入圆柱体地面半径: ");

double r = scanner.nextDouble();

System.out.println("请输入圆柱体高: ");

double h = scanner.nextDouble();

System.out.println("圆柱体体积: " + (Math.PI * Math.pow(r, 2) * h));

}

private void question3() {

System.out.println("Q3:");

Scanner scanner = new Scanner(System.in);

System.out.println("清输入年份: ");

int year = scanner.nextInt();

System.out.println(year + (year % 4 == 0 year % 100 != 0 || year % 400 == 0 ? "是" : "不是") + "闰年");

}

private void question4() {

System.out.println("Q4:");

double gdb = 100;

int i = 0;

for (; gdb gdb * 2; i++) {

gdb += gdb * 0.08;

}

System.out.println("经过" + i + "年,GDP可以翻一番");

}

private void question5() {

System.out.println("Q5:");

Scanner scanner = new Scanner(System.in);

System.out.println("请输入10个数,用空格隔开: ");

String input = scanner.nextLine();

String[] numbers = input.split("\\s");

int min = Integer.parseInt(numbers[0]);

int max = Integer.parseInt(numbers[0]);

for (int i = 1; i 10; i++) {

int number = Integer.parseInt(numbers[i]);

max = Math.max(number, max);

min = Math.min(number, min);

}

System.out.println("最大值: " + max + ", 最小值: " + min);

}

private void question6() {

System.out.println("Q6:");

Scanner scanner = new Scanner(System.in);

System.out.println("请输入第一个数: ");

int num1 = scanner.nextInt();

System.out.println("请输入第二个数: ");

int num2 = scanner.nextInt();

for (int i = Math.max(num1, num2); i 0; i--) {

if (num1 % i == 0 num2 % i == 0) {

System.out.println("最大公约数: " + i);

break;

}

}

for (int i = Math.max(num1, num2); ; i++) {

if (i % num1 == 0 i % num2 == 0) {

System.out.println("最小公倍数: " + i);

break;

}

}

}

}

java语言gdbc是什么意思

是jdbc不是gdbc就是java database connection也就是java操作数据库的一组api

java怎样将网页上面的数据以pdf的格式导出,求代码

需要用到一个pdf的jar包,去网上下载一个itextpdf.jar。导出pdf的格式都是需要自己用代码实现的,每一行 ,每一个列是什么格式,都需要自己写出来,是不能够自动生成的,反正很麻烦。我做的一个导出成pdf特定格式的东西,写了好几千行代码。相当头痛。

package com.dw.mqs.export;

import java.awt.Color;

import java.io.ByteArrayOutputStream;

import java.math.BigDecimal;

import java.net.URL;

import java.util.Date;

import java.util.HashSet;

import java.util.Hashtable;

import java.util.List;

import java.util.Map;

import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.dw.file.WebHelper;

import com.dw.mqs.MqsManager;

import com.dw.mqs.MqsUtilNew;

import com.dw.mqs.ProductItem;

import com.dw.mqs.ProjectBasicItem;

import com.dw.mqs.ProjectConfDetailItem;

import com.dw.mqs.ProjectConfVerItem;

import com.dw.mqs.ProjectConfig;

import com.dw.mqs.ProjectService;

import com.dw.mqs.Util;

import com.dw.system.Convert;

import com.dw.system.gdb.DBResult;

import com.dw.system.gdb.DataRow;

import com.dw.system.gdb.GDB;

import com.dw.user.User;

import com.dw.user.UserManager;

import com.dw.user.UserProfile;

import com.lowagie.text.Document;

import com.lowagie.text.Element;

import com.lowagie.text.Font;

import com.lowagie.text.Image;

import com.lowagie.text.PageSize;

import com.lowagie.text.Paragraph;

import com.lowagie.text.Rectangle;

import com.lowagie.text.pdf.BaseFont;

import com.lowagie.text.pdf.PdfPCell;

import com.lowagie.text.pdf.PdfPTable;

import com.lowagie.text.pdf.PdfWriter;

public class PdfService

{

Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);

ByteArrayOutputStream os = new ByteArrayOutputStream();

PdfWriter pdf = PdfWriter.getInstance(document, os);

Rectangle rect = new Rectangle(36, 54, 559, 788);

pdf.setBoxSize("art", rect);

pdf.setPageEvent(new TableHeader());

document.open();

BaseFont baseArialuni = BaseFont.createFont("res/ARIALUNI.TTF",

BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // Arial

// unicode字体

Font fontCN = new Font(baseArialuni, 9, Font.NORMAL, Color.BLACK);

Font fontCN8b = new Font(baseArialuni, 9, Font.BOLD, Color.BLACK);

Font fontCN12b = new Font(baseArialuni, 12, Font.BOLD, Color.BLACK);

Font fontCN9b = new Font(baseArialuni, 10, Font.BOLD, Color.BLACK);

Font fontCN9 = new Font(baseArialuni, 10, Font.NORMAL, Color.BLACK);

Font fontCN9b_blue = new Font(baseArialuni, 10, Font.BOLD, Color.BLUE);

PdfPTable table = null;

PdfPCell cell = null;

table = new PdfPTable(relativeWidths);

table.setWidthPercentage(100);

cell = new PdfPCell(new Paragraph(tit + "标题", fontCN12b));

cell.setColspan(root ? 12 : 10);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中

cell.setBorder(Rectangle.NO_BORDER);

table.addCell(cell);

}

如何使用jdb调试android的java程序

1)下载jdbshell并编译

因为我基本上每次一开始都要执行threads变量,所以我在开始wile循环前加了一句话

else

{

close(parent_to_child[0]);

write(parent_to_child[1], "threads\n",strlen("threads\n"));

while(1)

{

int i = 0;

line = readline ("");

...

}

}

编译后将jdbshell放到~/bin,或者将目录加到PATH里

出现无法打开readline.h的话,安装libreadline6和libreadline6-dev

2)仿照gdbclient,在build/envsetup.sh中加入jdbclient函数

function jdbclient()

{

local MY_SRC_PATH="$1"

if [ "$MY_SRC_PATH" ] ; then

MY_SRC_PATH=$1

echo $MY_SRC_PATH

else

echo "ROOT" $OUR_ROOT

MY_SRC_PATH="app_process"

fi

local PORT="$2"

if [ "$PORT" ] ; then

PORT=$2

else

PORT=":9000"

fi

local PID

local PROG="$3"

if [ "$PROG" ] ; then

PID=`pid $3`

echo tcp$PORT jdwp$PID

adb forward "tcp$PORT" "jdwp:$PID"

echo jdbshell -sourcepath $MY_SRC_PATH -attach localhost$PORT

jdbshell -sourcepath $MY_SRC_PATH -attach localhost$PORT

sleep 2

else

echo ""

echo "please specify app you want to debug:"

echo ""

fi

}

3)启动android模拟器,运行浏览器

4)jdbclient packets/app/Browser/src/ :9000 browser

第一个参数是你要load进来的代码的地址,如果你要load多个代码(调试的时候可以看),可以

export DEBUG_SRC_PATH=

然后

jdbclient $DEBUG_SRC_PATH :9000 browser

第二个参数是attach端口,如果9000有在用,可以用其他端口

第三个参数是要调试的应用,脚本里面根据

pid browser来取得进程id,所以你要保证

adb shell ps |grep browser

能够看到对应的进程

gdb java core 怎么调试

有一种办法是, 我们用gdb的step, 一步一步寻找.

这放在短小的代码中是可行的, 但要让你step一个上万行的代码, 我想你会从此厌恶程序员这个名字, 而把他叫做调试员.


本文名称:java代码gdb,java代码例子
链接URL:http://ybzwz.com/article/hsdche.html