Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 6 FirstFirst 1234 ... LastLast
Results 26 to 50 of 133

Thread: 500 Ways to Print 1 to 10

  1. #26
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: 500 Ways to Print 1 to 10

    Pretty sure I didn't see a solution that uses a stack.

    23. Java

    public class OneToTen
    {
         public static void main(String[] args)
         {
              Stack stack = new Stack();
              stack.push(10);
              stack.push(9);
              stack.push(8);
              stack.push(7);
              stack.push(6);
              stack.push(5);
              stack.push(4);
              stack.push(3);
              stack.push(2);
              stack.push(1);
              while (stack.size() > 0)
              {
                   System.out.println(stack.pop() + " ");
              }
         }
    }
     
    public class Stack
    {
         ArrayList<Integer> data;
     
         public Stack()
         {
              data = new ArrayList<Integer>();
         }
     
         public void push(int num)
         {
              data.add(num);
         }
     
         public int pop()
         {
              return data.remove(data.size() - 1);
         }
     
         public int size()
         {
              return data.size();
         }
    }

  2. #27
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: 500 Ways to Print 1 to 10

    24. java

    	public static void main(String[] args){		
    		String crazy = ":crazy nuts";
    		System.out.println(crazy.indexOf("c"));
    		System.out.println(crazy.indexOf("r"));
    		System.out.println(crazy.indexOf("a"));
    		System.out.println(crazy.indexOf("z"));
    		System.out.println(crazy.indexOf("y"));
    		System.out.println(crazy.indexOf(" "));
    		System.out.println(crazy.indexOf("n"));
    		System.out.println(crazy.indexOf("u"));
    		System.out.println(crazy.indexOf("t"));
    		System.out.println(crazy.indexOf("s"));
     
    	}

  3. #28
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: 500 Ways to Print 1 to 10

    25. Java
    public class OneToTen
    {
    	public static void main(String[] args)
    	{
    		Pattern pat = Pattern
    				.compile("([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])");
    		Matcher mat = pat.matcher("1234567890");
    		if (mat.find())
    		{
    			System.out.print(mat.group(1) + " ");
    			System.out.print(mat.group(2) + " ");
    			System.out.print(mat.group(3) + " ");
    			System.out.print(mat.group(4) + " ");
    			System.out.print(mat.group(5) + " ");
    			System.out.print(mat.group(6) + " ");
    			System.out.print(mat.group(7) + " ");
    			System.out.print(mat.group(8) + " ");
    			System.out.print(mat.group(9) + " ");
    			System.out.print(mat.group(1));
    			System.out.print(mat.group(10));
    		}
    	}
    }

  4. #29
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: 500 Ways to Print 1 to 10

    18. C++ (fixed (; )
    #include <iostream>
     
    int main()
    {
         int* a = new int[10];
         for (int i = 0; i < 10; i++)
         {
              *a = 10 - i;
              a++;
         }
         for (int i = 0; i < 10; i++)
         {
              cout << a* << " ";
              a--;
         }
         delete[] a;
         return 0;
    }

  5. #30
    Junior Member ordinarypeople's Avatar
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: 500 Ways to Print 1 to 10

    26. PHP
     
    <?php
     
    for($i=0;$i<=10;$i++)
     {
        echo"$i";
      }
     
    ?>
    thx to statement_missing
    Last edited by ordinarypeople; April 6th, 2010 at 11:08 AM.
    Uncaught exception: MYBRAIN.lang.NullPointerException 0.

  6. #31
    Junior Member ordinarypeople's Avatar
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: 500 Ways to Print 1 to 10

    27. pascal

    uses wincrt;
     
    var i : integer;
     
    begin
    i := 1;
    while i <= 10 do print(i)
    end.
    thx to vrainz
    Last edited by ordinarypeople; April 6th, 2010 at 11:09 AM.
    Uncaught exception: MYBRAIN.lang.NullPointerException 0.

  7. #32
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: 500 Ways to Print 1 to 10

    28. Java

    import java.util.Arrays;
     
    public class OneToTen {
        public static void main(String... arguments) {
            System.out.println(Arrays.toString(arguments));
        }
    }

    Execute it using something like
    java -cp . OneToTen 1 2 3 4 5 6 7 8 9 10
    // Json

  8. #33
    Junior Member ordinarypeople's Avatar
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: 500 Ways to Print 1 to 10

    29. VB6

    Private Sub Form_Load()
    AutoRedraw = True
    Print "Print number 1 - 10"
    For i = 1 To 10
         Print i
    Next
    End Sub



    again thx to vrainz
    Uncaught exception: MYBRAIN.lang.NullPointerException 0.

  9. #34
    Junior Member ordinarypeople's Avatar
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: 500 Ways to Print 1 to 10

    30.VB.Net

    credit to vrainz

    Public Class Form1
        Private b1 As Bitmap
        Private g1 As Graphics
     
        Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles 
     
    MyBase.Activated
            Static done As Boolean = False
            If Not done Then
                Size = New Size(300, 350)
                Text = "Print 1 - 10"
     
                b1 = New Bitmap(Width, Height, Me.CreateGraphics())
                g1 = Graphics.FromImage(b1)
                done = True
     
     
                        FormPrint("Print number from 1 - 10", 25, 10)
                        FormPrint("1", 25, 25)
                        FormPrint("2", 25, 40)
                        FormPrint("3", 25, 55)
                        FormPrint("4", 25, 70)
                        FormPrint("5", 25, 85)
                        FormPrint("6", 25, 100)
                        FormPrint("7", 25, 115)
                        FormPrint("8", 25, 130)
                        FormPrint("9", 25, 145)
                        FormPrint("10", 25, 160)
     
            End If
        End Sub
     
        Private Sub FormPrint(ByVal t$, ByVal x1%, ByVal y1%)
            g1.DrawString(t, New Font("Comic Sans MS", 12), Brushes.Chocolate, x1, y1)
            Me.CreateGraphics.DrawImage(b1, 0, 0)
        End Sub
     
        Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles 
     
    MyBase.Paint
            e.Graphics.DrawImage(b1, 0, 0)
        End Sub
    End Class
    Last edited by ordinarypeople; April 6th, 2010 at 12:56 PM.
    Uncaught exception: MYBRAIN.lang.NullPointerException 0.

  10. #35
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: 500 Ways to Print 1 to 10

    31. VFP (actually any XBase)
    FOR i=1 to 10
      ?i
    ENDF
    db

  11. #36
    Member wolfgar's Avatar
    Join Date
    Oct 2009
    Location
    the middle of the woods
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: 500 Ways to Print 1 to 10

    idk if this has been done or not

    32. Java

    for ( int i = 9; i > 0 ; i-- ) {
       system.out.println(10 - i);
    }
    Programming: the art that fights back

  12. #37
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: 500 Ways to Print 1 to 10

    #33 PHP

    <?php
     
    echo "1 2 3 4 5 6 7 8 9 10";
     
    ?>
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  13. #38
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: 500 Ways to Print 1 to 10

    LOL. This is getting a bit crazy..

    #34 Java

    import java.io.*;
    import java.text.*;
     
    public class Print1to10 {
     
        public static long size;
        public static double ans;
     
        public static void main(String[] args) throws Exception {
     
            Writer output = null;
            File file = new File("file.txt");
            output = new BufferedWriter(new FileWriter(file));
            output.write("JavaProgrammingForums.com");
            output.close();
            getSize(file);
        }
     
        public static void getSize(File file) {
            size = file.length();
            maths();
        }
     
        public static void maths() {
            double myDbl = 493.8;
            ans = (myDbl * size); 
            DecimalFormat df = new DecimalFormat("#");
            System.out.print(df.format(ans));
            partTwo();
        }
     
        public static void partTwo(){
            double ans2 = (1357.82 * 500);
            DecimalFormat df2 = new DecimalFormat("#");
            System.out.print(df2.format(ans2));
        }
    }

    Output:

    12345678910
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  14. #39
    Junior Member antony_t's Avatar
    Join Date
    May 2008
    Location
    http://www.yourcodefactory.com/forum/default.aspx
    Posts
    2
    My Mood
    Aggressive
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: 500 Ways to Print 1 to 10

    I’m not sure if there have been any C# entries yet, this has to be one of the longest methods yet as well!!

    35 C#

            protected void Page_Load(object sender, EventArgs e)
            {          
                string fileName = @"C:\Count.xml";
                CountToTenAndSerialize(fileName);
                CountToTenAndDeserialize(fileName);
            }
     
            public class Count
            {
                public int count;
            }
     
            private void CountToTenAndSerialize(string fileName)
            {
                List<Count> _countList = new List<Count>();
     
                int counter = 0;
                while(counter <= 10)
                {
                    Count countList = new Count();
                    countList.count = counter;
                    _countList.Add(countList);
                    counter++;
                }
     
                XmlSerializer serializer = new XmlSerializer(typeof(List<Count>));
                TextWriter tr = new StreamWriter(fileName);
     
                serializer.Serialize(tr, _countList);
                tr.Close();
            }
     
            private void CountToTenAndDeserialize(string fileName)
            {
                TextReader tr = new StreamReader(fileName);
                XmlRootAttribute rootAttribute = new XmlRootAttribute("ArrayOfCount");
                XmlSerializer deserializer = new XmlSerializer((typeof(List<Count>)), rootAttribute);
     
                List<Count> _countList = (List<Count>)deserializer.Deserialize(XmlReader.Create(tr));
                tr.Close();
     
                foreach (Count count in _countList)
                {
                    Response.Write(count.count.ToString() + "<br />");
                }
            }

  15. #40
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: 500 Ways to Print 1 to 10

    Quote Originally Posted by antony_t View Post
    I’m not sure if there have been any C# entries yet, this has to be one of the longest methods yet as well!!
    Nope, solutions 16 and 17 are longer Basically they're solving a ten dimensional linear algebra problem problem who's solution is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

    Some more fun with math:
    36. Java
    public class OneToTen
    {
    	public static void main(String[] args)
    	{
    		int num = 1;
    		for (int j = 0; j < 10; j++)
    		{
    			int carry = 0;
    			System.out.print(num + " ");
    			carry = num & 0x1;
    			num = num ^ 0x1;
    			for (int i = 1; i < 8; i++)
    			{
    				int nextCarry = num & (carry << 1);
    				num = num ^ (carry << 1);
    				carry = nextCarry;
    			}
    		}
    	}
    }

  16. #41
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: 500 Ways to Print 1 to 10

    #37 Java

    public class Print1to10 {
     
        public static void main(String[] args) {
     
            for (int a = 0; a < 11; a++) {
     
                switch (a) {
                case 1:
                    System.out.print("1 ");
                    break;
                case 2:
                    System.out.print("2 ");
                    break;
                case 3:
                    System.out.print("3 ");
                    break;
                case 4:
                    System.out.print("4 ");
                    break;
                case 5:
                    System.out.print("5 ");
                    break;
                case 6:
                    System.out.print("6 ");
                    break;
                case 7:
                    System.out.print("7 ");
                    break;
                case 8:
                    System.out.print("8 ");
                    break;
                case 9:
                    System.out.print("9 ");
                    break;
                case 10:
                    System.out.print("10 ");
                    break;
     
                }
            }
     
        }
     
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  17. #42
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: 500 Ways to Print 1 to 10

    #38 Shell Script

    for a in {1..10}
    do
    echo -n "$a "
    done
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  18. #43
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: 500 Ways to Print 1 to 10

    Hmm.. We are still a long way off 500 ways people! lol
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  19. #44
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: 500 Ways to Print 1 to 10

    #39
    	public static void main(String[] args) {		
    		long time = System.currentTimeMillis();
    		long temp = 0;
    		while ( temp < 10 ){
    			long current = System.currentTimeMillis();
    			if ( (current-time)/100 != temp ){
    				temp = (current-time)/100;
    				System.out.println( temp );
    			}
    		}
    	}

  20. #45
    Member Charlie's Avatar
    Join Date
    Jun 2010
    Location
    Sweden
    Posts
    41
    Thanks
    1
    Thanked 5 Times in 5 Posts

    Default Re: 500 Ways to Print 1 to 10

    #40 Java

     public static void main(String[] args) {
     
            String tester = "", fullString = "Count down";
     
            while(tester.length() < fullString.length()){
                System.out.println((tester.length() + 1));
                tester = tester + fullString.charAt(tester.length());
     
            }
        }

  21. #46
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: 500 Ways to Print 1 to 10

    #41 Java
    import java.util.concurrent.*;
     
    public class OneToTenThreads implements Runnable {
     
      ThreadPoolExecutor executor;
     
      public static void main(String[] args) {
        new OneToTenThreads().start();
      }
     
      private void start() {
        executor = new ThreadPoolExecutor(10, 10, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
        while (executor.getActiveCount() < executor.getCorePoolSize()) {
          executor.execute(this);
          try {
            Thread.sleep(10);
          } catch (InterruptedException ex) {
            ex.printStackTrace();
          }
        }
        System.exit(0);
      }
     
      @Override
      public void run() {
        System.out.println(executor.getActiveCount());
        try {
          Thread.sleep(200);
        } catch (InterruptedException ex) {
          ex.printStackTrace();
        }
      }
    }

  22. #47
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: 500 Ways to Print 1 to 10

    #42 Java
    public class OneToTenPrime {
     
      public static void main(String[] args) {
        new OneToTenPrime().countPrimes(4);
      }
     
      private void countPrimes(int count) {
        int primesFound = 0;
        int testNumber = 2;
     
        primesFound = 0;
        testNumber = 2;
        while (primesFound <= count) {
          System.out.println(testNumber - 1);
          primesFound += isPrime(testNumber) ? 1 : 0;
          testNumber++;
        }
      }
     
      private boolean isPrime(int n) {
        for (int i = 2; i <= (int) Math.sqrt(n); i++) {
          if (n % i == 0) {
            return false;
          }
        }
        return true;
      }
    }

  23. #48
    Member
    Join Date
    May 2010
    Posts
    38
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: 500 Ways to Print 1 to 10

    #43 Java - Converting from Base 33 (Triotrigesimal)!!!
    public class SandBox {
    	public SandBox() {
    		String[] base33 = new String[]{"B","M","10","1B","1M","20","2B","2M","30","3B"};
    		for (String s : base33) {
    			int result = 0;
    			boolean negative = false;
    			int i = 0, max = s.length();
    			int limit;
    			int multmin;
    			int digit;
     
    			if (max > 0) {
    				if (s.charAt(0) == '-') {
    					negative = true;
    					limit = Integer.MIN_VALUE;
    					i++;
    				} else
    					limit = -Integer.MAX_VALUE;
    				multmin = limit / 33;
    				if (i < max) {
    					digit = Character.digit(s.charAt(i++), 33);
    					result = -digit;
    				}
    				while (i < max) {
    					// Accumulating negatively avoids surprises near MAX_VALUE
    					digit = Character.digit(s.charAt(i++), 33);
    					result *= 33;
    					result -= digit;
    				}
    			}
     
    			if (negative)
    				System.out.print(result/11+" ");
    			else
    				System.out.print(-result/11+" ");
    		}
    	}
     
    	public static void main(String[] args) {
    		new SandBox();
    	}
    }

  24. #49
    Member
    Join Date
    May 2010
    Posts
    38
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: 500 Ways to Print 1 to 10

    ROFL

    #44 Java - Brute forcing randomized SHA512 hashes!!

    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import org.apache.commons.lang.StringUtils;
     
    /**
     * Test class for various things. Not relevent to anything
     * @author LordQuackstar
     */
    public class SandBox {
    	List<String> sha512hashes = new ArrayList(Arrays.asList(new String[]{
    				"bb90b23776dfde3333f63a924ebd2a039d80fc9280a7d1e9418529ced428930b69a95d55c4d9238f30b73789b4ebe0356bb9b8707025e3c527ca34825a160e2d",
    				"4774b6224b8e98b96b658092bee32c88c41b1a8c80dcfd7e1fdffc7be59c5f72eae3aecac37b0c7398154489066b0b022240a68daf4432849fabe75768faaf5e",
    				"3673a16a5983f5f5e04bf88d2c08e39631efe619726c5879d2d6907c00acb5d5689061b28cea52edab7c79dbfb450c961709c36c0d599b526c856e924f57e803",
    				"bb90b23776dfde3333f63a924ebd2a039d80fc9280a7d1e9418529ced428930b69a95d55c4d9238f30b73789b4ebe0356bb9b8707025e3c527ca34825a160e2d",
    				"3163a8d6a4540ecf1794ece0245f291154d30e1080359d2e994ef79c1a469aa0cd808769d9c7ee30ca342c6803d2ebcec3eb71a928d6db187dfb1fc2cf640395",
    				"84865a87593500aaaa29a49c382b84491eb97ac61a9264edd724aaaa81227040a557412b98841c14ed48b365f9a2f25faf7f59561d001bfa118070ec60dea8f3",
    				"08856a9022cc1f4b7c90b2d059e64acb6f6c5ac11da907d86db6a3072e9d821c59603c1ea94a2e537bea0a38320d678c482a66eaaf1a79c4d3432ea41e51b721",
    				"6ad275d26c200e81534d9996183c8748ddfabc7b0a011a90f46301626d709923474703cacab0ff8b67cd846b6cb55b23a39b03fbdfb5218eec3373cf7010a166",
    				"74c205daf6521128f2ad9009e44d9b608ea4940b5747ef6e74d616e4599ccaffcf12bb69ad38c8bbbfbd248b94fc8adddc3b091c7906cb05501dbea026e0d568",
    				"74a49c698dbd3c12e36b0b287447d833f74f3937ff132ebff7054baa18623c35a705bb18b82e2ac0384b5127db97016e63609f712bc90e3506cfbea97599f46f"}));
    	List<Integer> resultingNums = new ArrayList<Integer>();
     
    	public SandBox() {
    		for (String curHash : sha512hashes)
    			for (int num = 1; num <= 200; num++) {
    				MessageDigest md;
    				String message = Integer.toString(num);
    				try {
    					md = MessageDigest.getInstance("SHA-512");
     
    					md.update(message.getBytes());
    					byte[] mb = md.digest();
    					String out = "";
    					for (int i = 0; i < mb.length; i++) {
    						byte temp = mb[i];
    						String s = Integer.toHexString(new Byte(temp));
    						while (s.length() < 2)
    							s = "0" + s;
    						s = s.substring(s.length() - 2);
    						out += s;
    					}
    					if (out.equalsIgnoreCase(curHash)) {
    						resultingNums.add(num/11);
    						break;
    					}
     
    				} catch (NoSuchAlgorithmException e) {
    					System.out.println("ERROR: " + e.getMessage());
    				}
    			}
     
    		Integer[] ints = resultingNums.toArray(new Integer[0]);
    		Arrays.sort(ints);
    		System.out.println(StringUtils.join(ints," "));
    	}
     
    	 public static void main(String[] args) {
    		new SandBox();
    	}
    }

    (this is getting out of hand

  25. #50
    Junior Member p0oint's Avatar
    Join Date
    Jun 2010
    Location
    Macedonia
    Posts
    10
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Re: 500 Ways to Print 1 to 10

    #45

    int i=40;
    do
    {
    System.out.println((i%40+1));
    i++;
    }while(i<50);

Page 2 of 6 FirstFirst 1234 ... LastLast

Similar Threads

  1. print code to browser
    By bookface in forum Java Theory & Questions
    Replies: 4
    Last Post: April 21st, 2010, 01:09 AM
  2. print space
    By brainTuner in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 1st, 2010, 06:09 PM
  3. How to print results to screen
    By NinjaLink in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 19th, 2010, 01:46 PM
  4. Can someone please tell me why my code doesn't print out anything?
    By deeerek in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 6th, 2010, 08:35 AM
  5. print hex decimal value
    By ran830421 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 25th, 2009, 07:23 PM