public class Curiosity {
public static void main (String[]args){
System.out.println ("A curiosity");
http: //www.rgagnon.com/howto.html
System.out.println ("compile Ok!");
}
}
public class Foo {
static int fubar = 42;
Foo getFoo() {
return null;
}
public static void main(String args[]) {
Foo foo = new Foo();
System.out.println(foo.getFoo().fubar);
}
}
// output : 42
> I am new to java, and I really havent had time to do much work in it. > However, I have a small project that is due next week for my class. Can > anyone help me by providing some code? It should do the following; > > The program is simple. It should allow a user to input a string of digits, > and then output the sum of those digits. > > For example; the user inputs 3563 > the program would then output 17 (3+5+6+3)and one the answer (from E. Sosman) was
public class Homework{public static void main (String[] OoO) {for (int
oOo=0;oOo<OoO.length;++oOo) main (OoO [oOo]);} public static void main
(String oOo){String Oo0="9876543210"; long o0o=oOo.length()*Oo0.length
();for(int OoO=oOo.length();--OoO>=0;) {int O0O=Oo0.indexOf(oOo.charAt
(OoO));o0o-=O0O<0?012:++O0O;} main(oOo,o0o);} public static void main(
String Oo0,long oOo){System.out.print("Sum of digits in ");for(int O0O
=0;O0O<Oo0.length();++O0O)System.out.print(Oo0.charAt(O0O));System.out
.print(" = ");System.out.println(oOo);}}
Signature programs are short programs that people have been using as part of their signature in Usenet message or email. They are small programs, that are often rather cryptic because they have to save space as much as possible.
Here collection of classic signature programs, my own signature when I was a the Universite de Montreal it's there!
A signature program in Java is not an easy task because Java is lot more verbose than C. Here an attempt, try it to see the output!
class Howto{public static void main(String[] args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²ÀÐÊÀ\"".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>+
(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
Written and compiled by Réal Gagnon ©1998-2007
[ home ]