简体   繁体   English

给定LinkedList时返回大写字符的LinkedList

[英]Returning LinkedList of uppercase Characters when given a LinkedList

honestly I'm just really stuck right now on this problem and don't really know how to go about this. 老实说,我现在真的只是在这个问题上停留了,并不真正知道该怎么做。 I need to write a method where I am given a LinkedList of Characters (for example: {'a', 'A', 'd', 'X'}) and return a list of just the uppercase Characters (return: {'A', 'X'}). 我需要编写一个方法,给我一个字符链接列表(例如:{'a','A','d','X'})并返回仅包含大写字符的列表(返回:{' A','X'})。 How do I go about writing this program? 我该如何编写该程序?

import org.w3c.dom.Node;

public class ListExample {
public final class Node<T> {
    public final T       value;
    public       Node<T> next;

    public Node(T _value) {
        this( _value, null );
    }
    public Node(T _value, Node<T> _next) {
        value = _value;
        next  = _next;
    }
    @Override
    public String toString() {
        return "" + value;
    }
}

public static Node<Character> getUppercaseList(Node<Character> head) {
    Node<Character> tail = null;
    Node<Character> result = null;
    while(head != null) {

    }
    return null;
}
}

Thanks for any and all help! 感谢您提供的所有帮助!

Iterate through the list of characters, building up a list of uppercase ones. 遍历字符列表,建立大写字母列表。 If you are using Java8, then filter on the isUpperCase() method. 如果使用的是Java8,则对isUpperCase()方法进行过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM