Question

Functional-1 noX prev | next chance Given a list of strings, return a list where each string has all its x removed. Vi nox(

How do I do this in Java without using the functional API? I can't use anything special; this is for APCS

method header: public List noX(List strings)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public List<String> noX(List<String> strings) {
    List<String> list = new ArrayList<>();
    for (int i = 0; i < strings.size(); i++) {
        String result = "";
        for (int j = 0; j < strings.get(i).length(); j++) {
            if (strings.get(i).charAt(j) != 'x') {
                result += strings.get(i).charAt(j);
            }
        }
        list.add(result);
    }
    return list;
}
Add a comment
Know the answer?
Add Answer to:
How do I do this in Java without using the functional API? I can't use anything...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I write a java code that mimics charAt without using java API just primitives...

    How do I write a java code that mimics charAt without using java API just primitives and no charAt to be used? I know it comes from primitives but I am confused on how to assemble the loops to derive my own charAt code

  • Programming project in Java: You are allowed to use the following methods from the Java API:...

    Programming project in Java: You are allowed to use the following methods from the Java API: class String length charAt class StringBuilder length charAt append toString class Character any method Create a class called HW2 that contains the following methods: 1. isAlphabeticalOrder takes a String as input and returns a boolean: The method returns true if all the letters of the input string are in alphabetical order, regardless of case. The method returns false otherwise. Do not use arrays to...

  • I need help with this Java exercise. I'm not allowed to use imports and I tried...

    I need help with this Java exercise. I'm not allowed to use imports and I tried coding it but ended up failing. /** Given a String array, return an String array with duplicate Strings removed if the array contains duplicate values. <br> Note: Capital letters count. <br> <br> removeDuplicateStrings({"a"}) -> {"a"} <br> removeDuplicateStrings({"a", "b", "c", "d"}) -> {"a", "b", "c", "d"} <br> removeDuplicateStrings({"a", "a"}) -> {"a"} <br> removeDuplicateStrings({"A", "a"}) -> {"A", "a"} <br> removeDuplicateStrings({"these", "are", "the", "times"}) -> {"these", "are",...

  • how do i do this in basic java without using hashmat or anything complicated Two-Dimensional Arrays....

    how do i do this in basic java without using hashmat or anything complicated Two-Dimensional Arrays. Write the three functions described below. Demonstrate that your code works by calling each function and printing out the results. All of your code should be in one file. Upload your java code and a file containing the output of running your program to show that it works. Write a function called create2DIntArray that creates a two-dimensional array of integers between 0 and 10....

  • Need Help Using Java programming only import java.util.ArrayList; //Import anything you need here public class Dictionary...

    Need Help Using Java programming only import java.util.ArrayList; //Import anything you need here public class Dictionary {     // Declare any variables you feel necessary here     public Dictionary(/*DO NOT PUT ANY PARAMETERS HERE!*/) {         // Initialise those variables     }     /***      * @return number of terms currently in the dictionary hint: starts at 0 when      *         there are no terms      */     public int numberOfTerms() {         return 0;     }     /***     ...

  • WRITE IN JAVA: I've been trying to do this for hours and I can't figure this...

    WRITE IN JAVA: I've been trying to do this for hours and I can't figure this out. I tried the toArray method and I'm stumped. I'm not sure if the remove method is right aswell. If you need anymore info, let me know. I need the following methods completed: toArray Remove ReverseArray /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template...

  • Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored...

    Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored in an array. Implement all methods in ArrayStack class using resizable array strategy, i.e. usedoubleArray() Must throw StackException during exception events in methods:    peek(), pop(), ArrayStack(int initialCapacity) Do not change or add data fields Do not add new methods */ import java.util.Arrays; public class Arraystack«Т> implements Stack!nterface«T> private TI stack;// Array of stack entries private int topIndex; /7 Index of top entry private...

  • Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored in an ...

    Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored in an array. Implement all methods in ArrayStack class using resizable array strategy, i.e. usedoubleArray() Must throw StackException during exception events in methods:    peek(), pop(), ArrayStack(int initialCapacity) Do not change or add data fields Do not add new methods */ import java.util.Arrays; public class Arraystack«Т> implements Stack!nterface«T> private TI stack;// Array of stack entries private int topIndex; /7 Index of top entry private static...

  • Java programming How do i change this program to scan data from file and find the...

    Java programming How do i change this program to scan data from file and find the sum of the valid entry and count vaild and invalid entries The provided data file contains entries in the form ABCDE BB That is - a value ABCDE, followed by the base BB. Process this file, convert each to decimal (base 10) and determine the sum of the decimal (base 10) values. Reject any entry that is invalid. Report the sum of the values...

  • I have currently a functional Java progam with a gui. Its a simple table of contacts...

    I have currently a functional Java progam with a gui. Its a simple table of contacts with 3 buttons: add, remove, and edit. Right now the buttons are in the program but they do not work yet. I need the buttons to actually be able to add, remove, or edit things on the table. Thanks so much. Here is the working code so far: //PersonTableModel.java import java.util.List; import javax.swing.table.AbstractTableModel; public class PersonTableModel extends AbstractTableModel {     private static final int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT