473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hello World Day

Nepomuk
3,112 Expert 2GB
Hi everybody!
As was suggested here, today should be Hello World Day! So, here's my Hello World Program in Java:
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. public class HelloWorldDay {
  3.     public static void main(String[] args) {
  4.         ArrayList<Character> al = new ArrayList<Character>();
  5.         char[] array = {'H', '!', 'e', 'd', 'l', 'l', 'l', 'r', 'o', 'o', ' ', 'W'};
  6.         for(int i=0; i<array.length/2; i++) {
  7.             al.add(i,array[i*2]);
  8.         }
  9.         for(int i=array.length-1; i>=0; i-=2) {
  10.             al.add(al.size(),array[i]);
  11.         }
  12.         for(int i=0; i<al.size(); i++)
  13.             System.out.print(al.get(i));
  14.     }
  15. }
Greetings,
Nepomuk

PS.: This Thread will be unstuck tomorrow, so don't worry dear fellow mods.
Nov 21 '08 #1
2 1138
Ganon11
3,652 Expert 2GB
For our international friends,

Expand|Select|Wrap|Line Numbers
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5. public class HelloWorldDay {
  6.     private static ArrayList<String> greetings;
  7.  
  8.     public static void main(String[] args) {
  9.         load();
  10.         String response;
  11.         Random gen = new Random();
  12.         Scanner console = new Scanner(System.in);
  13.  
  14.         do {
  15.             System.out.println(greetings.get(gen.nextInt(greetings.size())));
  16.             System.out.print("Again? ");
  17.             response = console.nextLine();
  18.         } while (response.equals("YES") || response.equals("Yes") || response.equals("yes"));
  19.     }
  20.  
  21.     public static void load() {
  22.         greetings = new ArrayList<String>();
  23.         greetings.add("Hello, World!"); // English
  24.         greetings.add("Guten Tag, Welt!"); // German
  25.         greetings.add("Hola, Mundo!"); // Spanish
  26.         greetings.add("Bonjour, Monde!"); // French
  27.         greetings.add("Hola món!"); // Catalan
  28.         greetings.add("Ahoj, svete!"); // Czech
  29.         greetings.add("Hei, maailma!"); //Finnish
  30.                 greetings.add("Salve, munde!"); // Latin
  31.     }
  32. }
Just add your language if I don't have it!
Nov 21 '08 #2
Nepomuk
3,112 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. //...
  2.         greetings.add("Salve, munde!"); // Latin
  3. //...
Nov 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Andy Sutorius | last post by:
Has anyone successfully created a Hello World program without using Visual Studio.NET? If so, what IDE did you use and what namespaces did you import? Thanks! Andy Sutorius
2
by: ME | last post by:
I am trying to find a prewritten method for converting a string like this:"Hello World" to this "Hello\sWorld". I plan to use it to build a regular expression. Specifically I am looking for a...
17
by: Tim Judd | last post by:
I must not be grasping anything here. Just a simple application, as follows (as any first-program is...) ---- #include <iostream.h> int main() { cout <<"hello world"; return 0;
6
by: RC | last post by:
Hello World, I am try do call a JavaScript function from XSLT, but I got function not avaible error. See "????" below. Would someone out there tell me how? Thank Q! <xsl:stylesheet...
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
4
by: arnuld | last post by:
i am learning C and doing the exercise 1-1 of K&R2, where K&R ask to remove some parts of programme and experiment with error, so here i go: #include <stdio.h> int main () { printf('hello...
0
by: C.W.Holeman II | last post by:
As K&R state the hardest part is getting a first instance to work. So I am looking for a "hello, world!" example for adding an additional element to an XHTML file. <html> <head><title>Hello,...
1
by: James T. Dennis | last post by:
You'd think that using things like gettext would be easy. Superficially it seems well documented in the Library Reference(*). However, it can be surprisingly difficult to get the external details...
11
by: cj | last post by:
Perhaps someone knows how to do this. When I open a new ASP.NET web service application in VS 2008, it opens with a simple Hello World web service already written. I want to see this work. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.