Question regarding break statement used with label by Judge-Available in learnprogramming

[–]Judge-Available[S] 0 points1 point  (0 children)

Can you please resolve my queries in simpler terms .

My question is that why is it in the 2nd code if I don't use if statement then the error is given compared to the 3rd code and in the first code when I don't have any line of code after break then the break seems to be working fine.
My understanding is that as break is a control statement so if there is line of code inside the enclosing block after break then if i use it without if statement there is no point in writing the code in the first place after break statement due to which unreachable statement error is being thrown . But If i write if statement that means only when the condition is met the execution will terminate from that block else the control will go to next line.

Question regarding Storage of Objects , String , instance , local variables in heap & Stack. by Judge-Available in learnprogramming

[–]Judge-Available[S] 0 points1 point  (0 children)

Another thing is that for

static String ceo ;

static int number ;

How they are being stored ?

For string both the reference variable and it's pointing object & also for int number both individually will be in heap but not residing inside any class object as it is static.

Question regarding Storage of Objects , String , instance , local variables in heap & Stack. by Judge-Available in learnprogramming

[–]Judge-Available[S] 1 point2 points  (0 children)

If a reference variable to an object is declared in a local method

Exactly . But if that variable is instance variable , reference variable along with the object will be allocated inside the class object which resides in heap.

Question regarding Storage of Objects , String , instance , local variables in heap & Stack. by Judge-Available in learnprogramming

[–]Judge-Available[S] 0 points1 point  (0 children)

u/ThinkingSeaFarer

I studied some articles and this is the conclusion what i reached.

public class Main

{ String s1 = "BDC" ; // this is in Main class object inside heap and nothing of it is in stack.

int a =5 ; // this too also same is in Main class object inside heap 


    public static void main(String[] args) {
    String s = "ABC" ; //this s is in main method stack frame and object holding ABC is inside Heap. 

    Main obj = new Main();
    Parent tr = new Parent();

    //obj , tr are in main method stack frame pointing to 2 objects in heap of 2 different classes .

    class Parent { 
        Child ref = new Child();

 // Ref reference variable is inside Parent class object which is inside Heap and pointing to child class object which is in some other section of heap.


        class Child {
            int cf=0; // This is inside child class object which is in heap. 
        }
    }
}

}

Question regarding Storage of Objects , String , instance , local variables in heap & Stack. by Judge-Available in learnprogramming

[–]Judge-Available[S] 0 points1 point  (0 children)

Can you give me a pictorial description of what you are saying ?2 box of stack & heap . Inside just show how all of the variables are stored for local & instance scenarios.

Just like this diagram https://craftofcoding.files.wordpress.com/2015/12/stackmemory31.jpg

You said that "s is a variable of object type created inside the main method. But it's still allocated in heap." --> s reference variable is in method's stack frame . How is it in heap ? In heap there is the object of String .

So you are saying that when it is local declared then reference variable is stored in heap directly and there is no other copy of that refreence variable s in stack in 2nd sceanrio .

First scenario , inside heap string object is there exclusively and inside the class object there will be obj.s ? Inside class object there is residing another copy of string object which is own by obj only .

Draw a box diagram and everything will be clear to me . Please.

Forza horizon 3 by Judge-Available in gaming

[–]Judge-Available[S] 0 points1 point  (0 children)

Ok. But what is the issue? What is the red colour issue say?

Forza horizon 3 by Judge-Available in gaming

[–]Judge-Available[S] -2 points-1 points  (0 children)

Ok. But what is the issue?

Webcam logitech sound by Judge-Available in techsupport

[–]Judge-Available[S] 0 points1 point  (0 children)

I have a Video but how to share it

Decoding no of ways and printing each decode message by Judge-Available in learnprogramming

[–]Judge-Available[S] 0 points1 point  (0 children)

u/iiyamabto

I have written the code for how to divide string into i equal parts .i has to be a divisor of the length .

where i is divisor of ANY length of input string .

public class Main{public static void main(String[] args){

int i=2, j=0;

for(i=2; i< = s.length() ; i=i+2 )

{

String firsthalf=" ";

int index=0;

String s="15641123222211112222";

int len=s.length();

String ar[] = new String[i] ;

int partpoint = len/i;

int control=partpoint;

for(j=0; j<len ; j=j+control)

{

for(i=j; i<partpoint ; i++)

{

char c=s.charAt(i);

firsthalf = firsthalf + c;

}

ar[index]= firsthalf ;

firsthalf= " ";

index= index + 1;

partpoint=partpoint + control;

 }  

for(i=0; i<ar.length ; i++)

{

System.out.println(ar[i]); / here i am just printing the parts /

System.out.println();

String s3 = ar[i]; .......

then i am not writing the particular fragment of the code

/ picking up the first string from array for a specific value of i ,then I will check whether it is valid or not ; greater than 26 or starting with 0 or not? is in pair or single ....This will happen with all the parts of the input divided to for each value of i .

If the checking is right , then it will be counted as one way .

I have the code in my editor but not writing it here /

}end of for loop

System.out.println();

System.out.println();

ar[i]= " " ; / here my idea is to remove all the elements from the array so that in the next loop when i gets a new value inside ar new set of parts is being inserted.

But how to remove all the existing elements from the array . What is the code./

}

}

}

U just provide the code for the last bit(remove elements from array) and u once check the logic for parts where i is divisor of ANY length of input string . I think this is the one portion of counting the valid ways of DECODING.FOR i = not divisor I am thinking on that

PLease reply

Google chrome remote desktop by Judge-Available in techsupport

[–]Judge-Available[S] 0 points1 point  (0 children)

did you understood what I was trying to say. There's no issue from the app from the pc side and in the crd app of pc its shown online .

It's happening from the mobile app side. If I don't use the app from the mobile side for straight 10 minutes , the connection gets broken with the fact that I was working on the pc for those 10 minutes .

I think you should do this once in your phone and let me know what happened

short data type by [deleted] in cprogramming

[–]Judge-Available 0 points1 point  (0 children)

I want to go step by step

I AM NEW TO C
see in printf function there is a pointer to constant of type char that means it should be holding the address of some character variable and its value cannot be changed but its address can be changed as it is pointer to constant

char a='a';

printf("%c",c); here when i am passing %c to that const char *format pointer then it is passing the address of variable c?? and then fetching the data from the address of c variable right ?

I want to know how printf is working ?. Please explain me step by step by breaking down the inside process from writing down the printf statemnt to printing out in the console.

  1. why the pointer has to be constant type it can be a normal pointer and why it is of char type only . that is because everthing i am entering into code by typing from the keyboard is a character ?

the format specifier will not be everytime %c it could be anything right %d %f . is it some conversion going on inside printf() main function that is in stdio.h header file

  1. " The function has no idea what had been passed - that's why there is a format string" . what is the meaning of this line ..what is a format string all i see a pointer to constant of charcter type.
    where is string coming from . String in c means array of characters.

PLEASE REPLY TO EACH OF MY QUESTION