Skip to content

Conversation

@agrawal-aditi18
Copy link
Owner

No description provided.

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

Scanner sc = new Scanner(System.in);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make proper Indentation of the code

while(true) {
System.out.println("Select the operation you want to perform");
String[] arr = {"Exit()","append()", "countWords()", "replace()", "isPalindrome()", "splice()", "split()", "maxRepeat()", "sort()", "shift()", "reverse()"};
for (int i = 0; i < arr.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use descriptive variable names

while(true) {
System.out.println("Select the operation you want to perform");
String[] arr = {"Exit()","append()", "countWords()", "replace()", "isPalindrome()", "splice()", "split()", "maxRepeat()", "sort()", "shift()", "reverse()"};
for (int i = 0; i < arr.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use for loop in while

}

int choice = sc.nextInt();
sc.nextLine();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptive varible names

}


//append

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should be in descriptive manner

//sort
String sorting() {
String temp = original.toLowerCase();
int[] freq = new int[26];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write frequency in place of freq



for (int i = 0; i < temp.length(); i++) {
char ch = temp.charAt(i);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptive variable names

}
}

StringBuilder sb = new StringBuilder();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use string builder

int maxi=0;
char character=original.charAt(0);
for(int i=0;i<original.length();i++){
char ch = original.charAt(i);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptive names, spacing between operators in whole code

return new String(result);
}


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check your code again and write descriptive variable names and proper indention in the code is missing, add some space while using the operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants