「java点赞狂题」有赞java面试题

博主:adminadmin 2022-11-29 08:40:06 47

今天给各位分享java点赞狂题的知识,其中也会对有赞java面试题进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java编程题

1.package test;

import java.util.Iterator;

import java.util.Map;

import java.util.TreeMap;

public class Test {

public static void main(String[] args) {

String str = "afdjasdg$$jfsjdfjdjjdjdjdjdjdj";

int max=0;

Object chars=null;

Map tree = new TreeMap();

for (int i = 0; i str.length(); i++) {

char ch = str.charAt(i);

if ((ch = 1 ch = 255) ) {

if (!tree.containsKey(ch)) {

tree.put(ch, new Integer(1));

} else {

Integer in = (Integer) tree.get(ch) + 1;

tree.put(ch, in);

}

}

}

Iterator tit = tree.keySet().iterator();

while (tit.hasNext()) {

Object temp = tit.next();

if(max=Integer.parseInt(tree.get(temp)+""))

{

max=Integer.parseInt(tree.get(temp)+"");

chars=temp;

}

}

System.out.print(chars.toString() + "出现" + max + "次");

}

}

只要用assic码做范围就可以了.任何字符都可以过滤.

2.方法很多,hashmap或是arraylist,数组都可以的.就是对应关系而已.

package test;

public class ListTest {

static String[] to_19 = { "zero", "one", "two", "three", "four", "five",

"six", "seven", "eight", "nine", "ten", "eleven", "twelve",

"thirteen", "fourteen", "fifteen", "sixteen", "seventeen",

"eighteen", "nineteen" };

static String[] tens = { "twenty", "thirty", "forty", "fifty", "sixty",

"seventy", "eighty", "ninety" };

static String[] denom = { "", "thousand ", "million", "billion",

"trillion", "quadrillion", "quintillion", "sextillion",

"septillion", "octillion", "nonillion", "decillion", "undecillion",

"duodecillion", "tredecillion", "quattuordecillion",

"sexdecillion", "septendecillion", "octodecillion",

"novemdecillion", "vigintillion" };

public static void main(String[] argv) throws Exception {

long tstValue = 12345;

ListTest itoe = new ListTest();

System.out.println(itoe.english_number(tstValue));

}

private String convert_nn(int val) {

if (val 20) return to_19[val];

int flag = val / 10 - 2; if (val % 10 != 0)

return tens[flag] + "-" + to_19[val % 10];

else return tens[flag];

}

private String convert_nnn(int val) {

String word = "";

int rem = val / 100;

int mod = val % 100;

if (rem 0) {word = to_19[rem] + " hundred ";}

if (mod 0) {word = word + convert_nn(mod);}

return word;

}

public String english_number(long val) {

if (val 100) {System.out.println((int) val);return convert_nn((int) val);}

if (val 1000) {return convert_nnn((int) val); }

for (int v = 0; v denom.length; v++) {

int didx = v - 1;

long dval = new Double(Math.pow(1000, v)).longValue();

if (dval val) {

long mod = new Double(Math.pow(1000, didx)).longValue();

int l = (int) (val / mod);

long r = (long) (val - (l * mod));

String ret = convert_nnn(l) + " " + denom[didx];

if (r 0) {ret = ret + ", " + english_number(r);}

return ret;

}

}

return null;

}

}

JAVA实现点赞功能 if语句

Goods表设计的有问题啊

goods(赞数)应该在新闻表里

goods表只要存id

news_id(新闻id)

user_id(用户id)

发sql查是否已点赞的时候where条件判断news_id

user_id

select

count(1)

from

Goods

where

news_id=?

and

user_id=?

值大于0就代表已点赞

只等于0就插入点赞的数据

5道简单的JAVA编程题(高分悬赏)

很详细的帮你写下,呵呵,所以要给分哦!

1、

(1)源程序如下:

public class One {

public static void main(String[] args) {

String name = "张三";

int age = 23;

char sex = '男';

String myclass = "某某专业2班";

System.out.println("姓名:" + name);

System.out.println("姓名:" + age);

System.out.println("姓名:" + sex);

System.out.println("姓名:" + myclass);

}

}

(2)

编写完程序的后缀名是.java,如本题,文件名就是One.java。

开始\运行\cmd,进入“命令提示符窗口”,然后用javac编译器编译.java文件,语句:javac One.java。

(3)

编译成功后,生成的文件名后缀是.class,叫做字节码文件。再用java解释器来运行改程序,语句:java One

2、编写程序,输出1到100间的所有偶数

(1)for语句

public class Two1 {

public static void main(String[] args) {

for(int i=2;i=100;i+=2)

System.out.println(i);

}

}

(2)while语句

public class Two2 {

public static void main(String[] args) {

int i = 2;

while (i = 100) {

System.out.println(i);

i += 2;

}

}

}

(3)do…while语句

public class Two3 {

public static void main(String[] args) {

int i = 2;

do {

System.out.println(i);

i += 2;

}while(i=100);

}

}

3、编写程序,从10个数当中找出最大值。

(1)for循环

import java.util.*;

public class Three1 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int number;

int max = 0;

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

System.out.print("输入第" + (i + 1) + "个数:");

number = input.nextInt();

if (max number)

max = number;

}

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

}

}

(2)while语句

import java.util.*;

public class Three2 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int number;

int max = 0;

int i = 0;

while (i 10) {

System.out.print("输入第" + (i + 1) + "个数:");

number = input.nextInt();

if (max number)

max = number;

i++;

}

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

}

}

(3)do…while语句

import java.util.*;

public class Three3 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int number;

int max = 0;

int i = 0;

do {

System.out.print("输入第" + (i + 1) + "个数:");

number = input.nextInt();

if (max number)

max = number;

i++;

}while(i10);

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

}

}

4、编写程序,计算从1到100之间的奇数之和。

(1)for循环

public class Four1 {

public static void main(String[] args) {

int sum=0;

for(int i = 1;i=100;i+=2){

sum+=i;

}

System.out.println("1~100间奇数和:" + sum);

}

}

(2)while语句

public class Four2 {

public static void main(String[] args) {

int sum = 0;

int i = 1;

while (i = 100) {

sum += i;

i += 2;

}

System.out.println("1~100间奇数和:" + sum);

}

}

(3)do…while语句

public class Four3 {

public static void main(String[] args) {

int sum = 0;

int i = 1;

do {

sum += i;

i += 2;

} while (i = 100);

System.out.println("1~100间奇数和:" + sum);

}

}

5、

(1)什么是类的继承?什么是父类?什么是子类?举例说明。

继承:是面向对象软件技术当中的一个概念。如果一个类A继承自另一个类B,就把这个A称为"B的子类",而把B称为"A的父类"。继承可以使得子类具有父类的各种属性和方法,而不需要再次编写相同的代码。在令子类继承父类的同时,可以重新定义某些属性,并重写某些方法,即覆盖父类的原有属性和方法,使其获得与父类不同的功能。另外,为子类追加新的属性和方法也是常见的做法。继承需要关键字extends。举例:

class A{}

class B extends A{}

//成员我就不写了,本例中,A是父类,B是子类。

(2)编写一个继承的程序。

class Person {

public String name;

public int age;

public char sex;

public Person(String n, int a, char s) {

name = n;

age = a;

sex = s;

}

public void output1() {

System.out.println("姓名:" + name + "\n年龄:" + age + "\n性别:" + sex);

}

}

class StudentPerson extends Person {

String school, department, subject, myclass;

public StudentPerson(String sc, String d, String su, String m, String n,

int a, char s) {

super(n, a, s);

school = sc;

department = d;

subject = su;

myclass = m;

}

public void output2() {

super.output1();

System.out.println("学校:" + school + "\n系别:" + department + "\n专业:"

+ subject + "\n班级:" + myclass);

}

}

public class Five2 {

public static void main(String[] args) {

StudentPerson StudentPersonDemo = new StudentPerson("某某大学", "某某系别",

" 某专业", "某某班级", " 张三", 23, '男');

StudentPersonDemo.output2();

}

}

关于java点赞狂题和有赞java面试题的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-29,除非注明,否则均为首码项目网原创文章,转载请注明出处。