Results 1 to 3 of 3
  1. #1
    DeathByStorm is offline Member
    Join Date
    Mar 2017
    Posts
    8
    Rep Power
    0

    Default Program Crashing after running

    Program keeps crashing after it's done. Does anyone know what I need to do to fix it?

    Java Code:
    public class m
    {
    	public static void main(String [] args)
    	{
    		Scanner S = new Scanner(System.in);
    
    		System.out.println("Give me a String: ");
    		String s1 = S.nextLine();
    
    		System.out.println("Give me a number: ");
    		int n1 = S.nextInt();
    
    
    		//System.out.print(s1.charAt(0));
    
    		char c = s1.charAt(n1);
    		int count = 0;
    		int j = n1;
    		while(j <= s1.length())
    		{
    
    			System.out.print(s1.charAt(count) + "");
    			count = count + j;
    		}
    	}
    }
    Last edited by DeathByStorm; 03-11-2017 at 07:28 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Program Crashing after running

    crashing after it's done
    Please explain what "crashing" means.
    Copy the full text of any error message and paste it here.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Program Crashing after running

    What is the code in lines #16 ... #25 supposed to do? It doesn't make much sense to me ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Infinate Loop? (Crashing program)
    By kkid in forum New To Java
    Replies: 4
    Last Post: 10-02-2013, 10:22 PM
  2. Replies: 1
    Last Post: 04-24-2013, 09:42 AM
  3. why does the program keep running?
    By jwl in forum New To Java
    Replies: 1
    Last Post: 10-04-2012, 09:27 PM
  4. Not getting why the program is not running
    By jnjh in forum New To Java
    Replies: 5
    Last Post: 04-07-2011, 10:25 AM
  5. Help with running the program :)
    By dj_ee3 in forum New To Java
    Replies: 2
    Last Post: 02-27-2011, 11:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •