211 Posted Topics

Member Avatar for TheComputerGuy

/* Useful StringTokenizer */ [CODE]import java.util.*; import javax.swing.*; public class Date0 { public static void main(String args[]) { String text= JOptionPane.showInputDialog(null,"Type in the data in the format'02/14/2010'"); int ymd[] = new int[3]; StringTokenizer s = new StringTokenizer(text,"/"); for (int i=0; s.hasMoreTokens(); i++) ymd[i] = Integer.parseInt(s.nextToken()); text ="Your input is " …

Member Avatar for ~s.o.s~
0
188
Member Avatar for avataralien

import java.io.*; import java.util.*; public class Profile { public static void main (String [] args) { String name="",user="",pass="",add=""; int ch=0, con=0; Scanner scn = new Scanner(System.in); while(true){ System.out.println("Enter your profile\n"); System.out.print("Name:"); name = scn.nextLine(); System.out.print("Username:"); user = scn.nextLine(); System.out.print("Address:"); pass = scn.nextLine(); while(true){ // only numeric allowed try{ System.out.print("Mobile:"); con …

Member Avatar for avataralien
0
119
Member Avatar for aryanarora

Do you mean [URL="http://www.roseindia.net/java/beginners/DelayExample.shtml"]the program [/URL]?

Member Avatar for tong1
0
75
Member Avatar for manailz

An e-book: [URL="http://www.ebookee.net/Concepts-of-Programming-Languages-7th-Edition-_35213.html"]Concepts of Programming Languages (7th Edition) [/URL]by Robert W. Sebesta [url]http://www.ebookee.net/Concepts-of-Programming-Languages-7th-Edition-_35213.html[/url] is also helpful.

Member Avatar for tong1
0
154
Member Avatar for tong1

/* The following programs are written to guard the input. The input is requested as an non-negative integer.Is there other method to do so? */ /* Operation on DOS window: "PositiveInt1" receives a positive integer only. */ import java.util.*; public class PositiveInt1{ static int factorial(int n){ int fac=1; if ((n<0) …

Member Avatar for NormR1
0
129
Member Avatar for prem2

1. The difference is in the name of the classes. 2. The Java language defines the signature (format) of the only main method in a class as public static void main(String args[]) {} meanwhile the name of the array of String may be given differently, e.g. public static void main(String …

Member Avatar for tong1
0
111
Member Avatar for tong1

/* In the following method, why the factorial goes wrong when n>12 ? */ static int factorial(int n){ int fac=1; if ((n<0) || (n>12)) return -1; for (int i=2; i<=n;i++) fac *=i; return fac; }

Member Avatar for tong1
0
1K
Member Avatar for prem2

An identifier is a symbol that establishes the identity of the one bearing it. [url]http://dict.cn/identifier[/url] It could also be a name of a constant.

Member Avatar for tong1
0
72
Member Avatar for Dokka

class Rock{ double weight; static int total=0; public Rock(double w){ setWeight(w); System.out.println("Rock " + ++total + " is created"); } void roll(){ weight *=1.2; } void setWeight(double d){ //成员方法 weight = d>0?d:1; } double getWeight( ){ return weight; } } public class RockTest{ public static void main(String args[]){ Rock rock[]= …

Member Avatar for tong1
0
271
Member Avatar for Web_Sailor

Is your JLabel's instance on a background painted by the Graphics in AWT? If the background is made by the Graphics's object, there will be a trouble. The stuff in AWT is considered as heavyweighted while the stuff, such as JLabel's instance in swing, lightweighted. The heaveweighted stuff always "overwrites" …

Member Avatar for Web_Sailor
0
3K
Member Avatar for darling332001

[code]import java.util.*; class cat{ String name; int age; double weight; String breed; boolean declawed; public cat(String s, int n, double d, String bs, boolean dec){ age=n; name = s; weight = d; breed = bs; declawed = dec; } public String getName(){ return name; } public int getAge(){ return age; …

Member Avatar for tong1
0
268

The End.